SELECTcolumn_name, data_type, is_nullable, column_default FROMinformation_schema.columns WHEREtable_name ='<table name>'; ci_database_test01=#SELECTcolumn_name, data_type, is_nullable, column_default ci_database_test01-#FROMinformation_schema.columns ci_database_test01-#WHEREtable_name ='pg...
ALTERTABLEtable_nameALTERCOLUMNcolumn_nameSETNOTNULL; 将产品表的name字段设置为非空: test=# \d products;Table"hr.products"Column|Type|Collation|Nullable|Default---+---+---+---+---product_no|integer||notnull|name|text|||price|numeric|||Indexes: "products_pkey"PRIMARYKEY, btree (product_n...
CREATE TABLE rtable(c1 INT, c2 VARCHAR(10)) PARTITION BY RANGE(c1); ALTER TABLE rtable ADD CONSTRAINT pk_rtable PRIMARY KEY(c1); \d rtable Table "public.rtable" Column | Type | Collation | Nullable | Default ---+---+---+---+--- c1 | integer | | not null | c2 | charact...
> CREATE TABLE t( pk smallint, t char(2) ); > CREATE VIEW vw_t AS SELECT * FROM t; 1. 2. 当然,视图和表格都反映了相同的字段结构 > \d t Table "public.t" Column | Type | Collation | Nullable | Default ---|---|---|---|--- pk | smallint | | | t | character(2) ...
postgres=# CREATE TABLE score(stuid int4, chinese int2, math int2, sum_score int2 GENERATED ALWAYS AS (chinese+math) STORED ); CREATE TABLE postgres=# \d score Table "public.score" Column | Type | Collation | Nullable | Default ---+---+---+---+--- stuid | integer | | | ch...
Table "public.t" Column | Type | Collation | Nullable | Default ---+---+---+---+--- a | integer | | | b | text | | | Indexes: "i" btree (b) postgres=# select relpages,reltuples from pg_class where relname = 't'; relpages | reltuples ---+--- 1 | 100 (1...
create table t_f(f1 int not null,f2 int); postgres=# ALTER TABLE t_f ADD CONSTRAINT t_f_f1_fkey FOREIGN KEY (f1) REFERENCES t_p (f1); ALTER TABLE postgres=# \d+ t_f Table"public.t_f" Column|Type|Collation|Nullable|Default|Storage|Stats target|Description ...
Unlogged table "public.test0329" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---+---+---+---+---+---+---+--- id | integer | | | | plain | | ``` ` ### 场景1:重启实例 在控制台上点击重启按钮...
ALTER TABLE customers DETACH PARTITION cust_others; postgres=# \d+ customers Partitioned table "public.customers" Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ---+---+---+---+---+---+---+---+--- id | integer | | | | pl...
postgres=# alter table percona.employee set (autovacuum_vacuum_scale_factor=0); postgres=# postgres=# \d+ percona.employee Table "percona.employee" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description