Background information
You can obtain the table creation statements in Oracle by DBMS_METADATA.GET_DDL functions, but PolarDB O Edition is not supported.
New solution
an-> \d+ t1 Table "public.t1" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description --------+-----------------------+-----------+----------+---------+----------+--------------+------------- id | integer | | | | plain | | name | character varying(30) | | | | extended | | Indexes: "idx1" UNIQUE, btree (id) "idx2" btree (name) Check constraints: "con1" CHECK (id < 2000000) Access method: heap
Note\d+
can see the table structure, but not the table creation statement.- This can be achieved by creating a function:
psql=#create extension plperlu; postgres=# CREATE OR REPLACE FUNCTION GET_DDL(text) RETURNS text AS 'my $cmd=shift; return `cd /tmp;$cmd`;' LANGUAGE plperlu; CREATE FUNCTION postgres=# select GET_DDL('pg_dump -s -t t1 ddl | egrep -v "^--|^$"'); get_ddl ---------------------------------------------------------------- CREATE TABLE public.t1 ( + id integer, + name character varying(30), + CONSTRAINT con1 CHECK ((id < 2000000)) + ); + ALTER TABLE public.t1 OWNER TO postgres; + CREATE UNIQUE INDEX idx1 ON public.t1 USING btree (id); + CREATE INDEX idx2 ON public.t1 USING btree (name); +
- You can view the client in a management tool such as pgadmin and dbeaver. dbeaver is used as an example: