DESCRIBE
Function
Views the structure of a specified table.
Precautions
- You need to specify the schema corresponding to the temporary table for query.
- All participating columns of a composite primary key index are displayed as PRI in the Key column.
- All participating columns of the composite unique index are displayed as UNI in the Key column.
- If a column is involved in the creation of multiple indexes, the Key column is displayed based on the first index created in the column.
- The generated column is displayed in Default.
- Table synonyms are not supported.
Syntax
{DESCRIBE | DESC} tbl_name
Parameter Description
{DESCRIBE | DESC}
The effect of using DESCRIBE is equivalent to that of using DESCRIBE.
tbl_name
Table name. You can specify a table name or **schema\_name.table\_name**.
Examples
--Create a test table.
openGauss=# CREATE TABLE test2
openGauss-# (
openGauss(# id int PRIMARY KEY
openGauss(# );
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test2_pkey" for table "test2"
CREATE TABLE
openGauss=# create table test
openGauss-# (
openGauss(# a SERIAL,
openGauss(# b varchar(10),
openGauss(# c varchar(10),
openGauss(# d varchar(10),
openGauss(# e varchar(10),
openGauss(# f varchar(10),
openGauss(# g varchar(10) DEFAULT 'g',
openGauss(# h varchar(10) NOT NULL,
openGauss(# i int DEFAULT 0,
openGauss(# j int DEFAULT 0,
openGauss(# k int GENERATED ALWAYS AS (i + j) STORED,
openGauss(# l int DEFAULT 0,
openGauss(# m int CHECK (m < 50),
openGauss(# PRIMARY KEY (a, b),
openGauss(# FOREIGN KEY(l) REFERENCES test2(id)
openGauss(# );
NOTICE: CREATE TABLE will create implicit sequence "test_a_seq" for serial column "test.a"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_pkey" for table "test"
CREATE TABLE
openGauss=# CREATE UNIQUE INDEX idx_c on test (c);
CREATE INDEX
openGauss=# CREATE UNIQUE INDEX idx_d_e on test (d, e);
CREATE INDEX
openGauss=# CREATE INDEX idx_f on test (f);
CREATE INDEX
--View the structure of the test table.
openGauss=# desc test;
Field | Type | Null | Key | Default | Extra
-------+-----------------------+------+-----+---------------------------------+-------
a | integer | NO | PRI | nextval('test_a_seq'::regclass) |
b | character varying(10) | NO | PRI | NULL |
c | character varying(10) | YES | UNI | NULL |
d | character varying(10) | YES | UNI | NULL |
e | character varying(10) | YES | UNI | NULL |
f | character varying(10) | YES | MUL | NULL |
g | character varying(10) | YES | | 'g'::character varying |
h | character varying(10) | NO | | NULL |
i | integer | YES | | 0 |
j | integer | YES | | 0 |
k | integer | YES | | (i + j) |
l | integer | YES | MUL | 0 |
m | integer | YES | | NULL |
(13 rows)
openGauss=# desc public.test;
Field | Type | Null | Key | Default | Extra
-------+-----------------------+------+-----+---------------------------------+-------
a | integer | NO | PRI | nextval('test_a_seq'::regclass) |
b | character varying(10) | NO | PRI | NULL |
c | character varying(10) | YES | UNI | NULL |
d | character varying(10) | YES | UNI | NULL |
e | character varying(10) | YES | UNI | NULL |
f | character varying(10) | YES | MUL | NULL |
g | character varying(10) | YES | | 'g'::character varying |
h | character varying(10) | NO | | NULL |
i | integer | YES | | 0 |
j | integer | YES | | 0 |
k | integer | YES | | (i + j) |
l | integer | YES | MUL | 0 |
m | integer | YES | | NULL |
(13 rows)
openGauss=# describe public.test;
Field | Type | Null | Key | Default | Extra
-------+-----------------------+------+-----+---------------------------------+-------
a | integer | NO | PRI | nextval('test_a_seq'::regclass) |
b | character varying(10) | NO | PRI | NULL |
c | character varying(10) | YES | UNI | NULL |
d | character varying(10) | YES | UNI | NULL |
e | character varying(10) | YES | UNI | NULL |
f | character varying(10) | YES | MUL | NULL |
g | character varying(10) | YES | | 'g'::character varying |
h | character varying(10) | NO | | NULL |
i | integer | YES | | 0 |
j | integer | YES | | 0 |
k | integer | YES | | (i + j) |
l | integer | YES | MUL | 0 |
m | integer | YES | | NULL |
(13 rows)
Helpful Links
N/A
Feedback