create_comments.sql
text/x-sql
Filename: create_comments.sql
Type: text/x-sql
Part: 0
CREATE SCHEMA myschema;
COMMENT ON SCHEMA myschema IS 'schema comment';
CREATE DOMAIN us_postal_code AS TEXT
CHECK(
VALUE ~ '^\\d{5}$'
OR VALUE ~ '^\\d{5}-\\d{4}$'
);
COMMENT ON DOMAIN us_postal_code IS 'domain comment';
CREATE DOMAIN uncommented_domain AS TEXT CHECK(true);
COMMENT ON TABLESPACE pg_default IS 'default tablespace';
CREATE TABLE mytbl (a serial PRIMARY KEY, b int);
COMMENT ON TABLE mytbl IS 'example table';
COMMENT ON SEQUENCE mytbl_a_seq IS 'serial sequence';
COMMENT ON COLUMN mytbl.a IS 'column comment';
CREATE TABLE myschema.another_tbl (a int);
ALTER TABLE myschema.another_tbl ADD CONSTRAINT a_chk_con CHECK(a != 0);
COMMENT ON TABLE myschema.another_tbl IS 'another_tbl comment';
COMMENT ON CONSTRAINT a_chk_con ON myschema.another_tbl IS 'constraint comment';
CREATE INDEX myidx ON mytbl (a);
COMMENT ON INDEX myidx IS 'example index';
ALTER TABLE mytbl ADD CONSTRAINT mycon CHECK (b < 100);
COMMENT ON CONSTRAINT mycon ON mytbl IS 'constraint comment';
CREATE VIEW myview AS SELECT * FROM mytbl;
COMMENT ON VIEW myview IS 'view comment';
CREATE TABLE dummy_tbl (a int);
CREATE RULE "myrule" AS
ON INSERT TO dummy_tbl
DO INSTEAD NOTHING;
COMMENT ON RULE "myrule" ON dummy_tbl IS 'bogus rule';
CREATE FUNCTION ex_trg_func() RETURNS trigger AS $$
BEGIN
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
COMMENT ON FUNCTION ex_trg_func() IS 'function comment';
create trigger ex_trg BEFORE INSERT OR UPDATE ON mytbl
for each row execute procedure ex_trg_func();
COMMENT ON TRIGGER ex_trg ON mytbl IS 'example trigger';
CREATE AGGREGATE public.myavg (float8)
(
sfunc = float8_accum,
stype = float8[],
finalfunc = float8_avg,
initcond = '{0,0,0}'
);
COMMENT ON AGGREGATE public.myavg (float8) IS 'aggregate comment';
CREATE FOREIGN DATA WRAPPER dummy;
CREATE FOREIGN DATA WRAPPER dummy2;
CREATE FOREIGN DATA WRAPPER uncommented_fdw;
COMMENT ON FOREIGN DATA WRAPPER dummy IS 'dummy fdw';
COMMENT ON FOREIGN DATA WRAPPER dummy2 IS 'dummy2 fdw';
CREATE SERVER my_foreign_server FOREIGN DATA WRAPPER dummy;
CREATE SERVER uncommented_server FOREIGN DATA WRAPPER dummy2;
COMMENT ON SERVER my_foreign_server IS 'dummy foreign server';
CREATE FOREIGN TABLE my_foreign_table (a int) SERVER my_foreign_server;
COMMENT ON FOREIGN TABLE my_foreign_table IS 'foreign table comment';
CREATE FOREIGN TABLE uncommented_ft (a int) SERVER my_foreign_server;
CREATE FOREIGN TABLE myschema.my_ft2 (a int) SERVER my_foreign_server;
COMMENT ON FOREIGN TABLE myschema.my_ft2 IS 'another foreign table comment';
CREATE SEQUENCE my_seq;
COMMENT ON SEQUENCE my_seq IS 'sequence comment';
CREATE TYPE compfoo AS (f1 int, f2 text);
COMMENT ON TYPE compfoo IS 'type comment';
-- after intarray contrib extension installed:
CREATE EXTENSION intarray;
COMMENT ON OPERATOR CLASS gist__int_ops USING gist IS 'comment for gist__int_ops';
CREATE OPERATOR FAMILY dummy_opf USING btree;
COMMENT ON OPERATOR FAMILY dummy_opf USING btree IS 'operator family comment';