How to query table names and column names in Oracle

Source: Internet
Author: User

The following articles mainly introduce the content of the Oracle query table name and table column name, as well as the code of its actual application, if you have a desire to understand the relevant content of this article, the following describes the specific content of this article. I hope you will gain some benefits.

1. query Table Name:

Copy the Code as follows:

 
 
  1. Select table_name, tablespace_name,
    Temporary from user_tables [where table_name = table name]

Where: table_name: Table Name varchar2 (30 ));

 
 
  1. Tablespace_name: The tablespace that stores the table name varchar230 ));

Temporary: whether it is a temporary table varchar21 )).

 
 
  1. eg: select table_name,tablespace_name,
    temporary from user_tables where table_name='TEST_TEMP'; 

Result:

 
 
  1. --------------------------------------------------------------------------------  
  2. table_name tablespace_name temporary  
  3. TEST_TEMP SDMP N  
  4. --------------------------------------------------------------------------------  

Note: The table name variable value must be capitalized.

2. query the Oracle table column Name:

Copy the Code as follows:

 
 
  1. Select column_name, data_type,
    Data_length, data_precision, data_scale from user_tab_columns [where table_name = table name];

Where: column_name: column name varchar2 (30 ));

Data_type: column data type varchar2 (106 ));

Data_length: column length number );

 
 
  1. eg:select column_name,data_type ,
    data_length,data_precision,data_scale from user_tab_columns where table_name='TEST_TEMP'; 

Result:

 
 
  1. --------------------------------------------------------------------------------  
  2. column_name data_type data_length data_precision data_scale  
  3. ID NUMBER 22 0  
  4. NAME NVARCHAR2 20  
  5. SEX CHAR 1  
  6. GRADE NVARCHAR2 10  
  7. --------------------------------------------------------------------------------  

Note: The table name variable value must be capitalized.

In addition, you can use all_tab_columns to obtain the data of the relevant table.

 
 
  1. eg:select * from all_tab_columns where table_name='TEST_TEMP';  

The above content is an introduction to the Oracle query table name and table column name. I hope you will have some gains.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.