In Oracle, you can use the "select ... From all_tab_columns where table_name=upper('table name') AND owner=upper('database login user name');" statement to query the data type of the database table .
The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.
The syntax of oracle query data type is as follows:
select column_name,data_type,DATA_LENGTH From all_tab_columns where table_name=upper('表名') AND owner=upper('数据库登录用户名');
The example is as follows:
select column_name,data_type,DATA_LENGTH From all_tab_columns where table_name=upper('t_department') AND owner=upper('scott')
Expand knowledge:
1. View the field name and data type
select * from cols WHERE TABLE_name=upper('表名'); (user_tab_columns缩写cols)
2. View the data type of the specified column
select DATA_TYPE from User_Tab_Columns t where t.column_name=upper('列名') and t.table_name =upper(trim('表名'));
3. View all columns
select * from user_tab_columns where table_name = upper(‘表名’);
4. View certain columns
select column_name,data_type,data_length,DATA_PRECISION ,DATA_SCALE from all_tab_columns where table_name=upper('表名');
5. You can view all constraints through user_constraints
select * from user_constraints where table_name = upper('表名');
6. View primary key constraints:
select * from user_constraints where constraint_type='P' and TABLE_name=upper('表名');
Recommended tutorial: "Oracle Video tutorial》
The above is the detailed content of How to query data type in oracle. For more information, please follow other related articles on the PHP Chinese website!