Home > Database > Oracle > body text

How to query data type in oracle

WBOY
Release: 2022-05-13 16:19:26
Original
9661 people have browsed it

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 .

How to query data type in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

How to query data type in oracle

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('数据库登录用户名');
Copy after login

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')
Copy after login

Expand knowledge:

1. View the field name and data type

select * from cols WHERE TABLE_name=upper('表名'); (user_tab_columns缩写cols)
Copy after login

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('表名'));
Copy after login

3. View all columns

select * from user_tab_columns where table_name = upper(‘表名’);
Copy after login

4. View certain columns

select column_name,data_type,data_length,DATA_PRECISION ,DATA_SCALE from all_tab_columns where table_name=upper('表名');
Copy after login

5. You can view all constraints through user_constraints

select * from user_constraints where table_name = upper('表名');
Copy after login

6. View primary key constraints:

select * from user_constraints where constraint_type='P'
and TABLE_name=upper('表名');
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template