[postgreSql]postgreSql数据库、模式、表、函数的删除与创建

1.删除/新增数据库
    DROP DATABASE "testDB";
    CREATE DATABASE "testDB" WITH OWNER = test_user;
2.删除/新增模式
    DROP SCHEMA "testSchema" ;
    CREATE SCHEMA "testSchema" AUTHORIZATION postgres;
3.删除/新增表
    DROP TABLE "testSchema".students;
    CREATE TABLE "testSchema".students
    (
    id integer NOT NULL DEFAULT nextval('"testSchema".students_id_seq'::regclass),
    name character varying COLLATE pg_catalog."default",
    age integer,
    CONSTRAINT students_pkey PRIMARY KEY (id)
    )
4.删除/新增/使用函数
    DROP FUNCTION "testSchema". getStudentNameById;
    CREATE FUNCTION "testSchema"."getStudentNameById"(IN id integer DEFAULT 0)
    RETURNS character varying
    LANGUAGE 'sql'
    AS $BODY$
    函数主体
    $BODY$;
    SELECT "testSchema". getStudentNameById();

posted @ 2018-09-26 09:55  vickylinj  阅读(928)  评论(0编辑  收藏  举报