In Oracle, SQL queries table information because the data structure design of some modules of the project is not strictly in accordance with a certain specification design, it can only be
To query the data structure, you need to query the following information: field name, data type, whether it is null, default value, primary key, foreign key, and so on. Www.2cto.com searched for the above information on the Internet, summarized as follows: 1. query table Basic Information select utc. column_name, utc. data_type, utc. data_length, utc. data_precision, utc. data_Scale, utc. nullable, utc. data_default, ucc. commentsfrom user_tab_columns utc, user_col_comments uccwhere utc. table_name = ucc. table_name and utc. column_name = ucc. column_name and utc. table_name = 'onlinexls' order by column_id Note: order by column_id indicates that the result is displayed in the order in which the data structure is designed. 2. query the table's primary key www.2cto.com select col. column_namefrom user_constraints con, user_cons_columns colwhere con. constraint_name = col. constraint_name and con. constraint_type = 'p' and col. table_name = 'onlinexls' 3. query the foreign key www.2cto.com select distinct (ucc. column_name) column_name, rela. table_name, rela. column_name column_name1from user_constraints uc, user_cons_columns ucc, (select t2.table _ name, t2.column _ name, t1.r _ constraint_name from user_constraints t1, user_cons_columns t2 where t1.r _ constraint_name = t2.constraint _ name and t1.table _ name = 'onlinexls') relawhere uc. constraint_name = ucc. constraint_name and uc. r_constraint_name = rela. r_constraint_name and uc. table_name = 'onlinexls'