1,describe command
Here's how to use it:
Sql> describe NCHAR_TST (nchar_tst as table name)
The results shown are as follows:
is the name empty? Type
----------------------------------------- -------- ----------------------------
NAME NCHAR (6)
ADDR NVARCHAR2 (16)
SAL Number (9,2)
2,dbms_metadata. GET_DDL Bag
Here's how to use it:
[SQL]View PlainCopy
- Sql> SELECT dbms_metadata. GET_DDL (' TABLE ',' nchar_tst ') from DUAL;
If the displayed results are not complete, as follows:
CREATE TABLE "SCOTT". " Nchar_tst "
("NAME" NCHAR (6),
"ADDR" NVARCHAR2 (16
Then modify the following:
[SQL]View PlainCopy
- Sql> SET LONG 9999
- Sql> SELECT dbms_metadata. GET_DDL (' TABLE ',' nchar_tst ') from DUAL;
The following results are displayed:
Dbms_metadata. GET_DDL (' TABLE ', ' nchar_tst ')
------------------------------------------------------------------------------
CREATE TABLE "SCOTT". " Nchar_tst "
("NAME" NCHAR (6),
"ADDR" NVARCHAR2 (16),
"SAL" Number (9,2)
) PCTFREE pctused Initrans 1 Maxtrans 255 LOGGING
STORAGE (INITIAL 12288 NEXT 12288 minextents 1 MAXEXTENTS 249 pctincrease 50
Freelists 1 FREELIST GROUPS 1 buffer_pool DEFAULT) tablespace "SYSTEM"
3, Method:
Federated queries through User_tab_cols, user_col_comments, user_constraints, user_cons_columns tables in Oracle.
User_tab_cols is used to obtain the column information of the corresponding user table;
User_col_comments is used to obtain the corresponding User table column annotation information;
User_constraints is used to obtain the constraints of the user table;
User_cons_columns a user-accessible column in a constraint.
Example code:
[SQL]View PlainCopy
- Select T.table_name,t.column_name,t.data_type,t.data_length,t.nullable,t.column_id,c.comments,
- (SELECT case is t.column_name=m.column_name then 1 ELSE 0 END from DUAL) IsKey
- From User_tab_cols T, user_col_comments C, (select M.column_name from user_constraints s, user_cons_columns M
- where lower (m.table_name) =' us_cities ' and m.table_name=s.table_name
- and M.constraint_name=s.constraint_name and s.constraint_type=' P ') m
- WHERE lower (t.table_name) =' us_cities '
- and C.table_name=t.table_name
- and C.column_name=t.column_name
- and t.hidden_column=' NO '
- ORDER BY t.column_id
Several ways Oracle views the table structure