Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use SQL statements to query all MySQL,SQLServer,Oracle database and table names, field names

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to use SQL statements to query all MySQL,SQLServer,Oracle database names and table names, field names, the article is very detailed, has a certain reference value, interested friends must read it!

Query all database and table names in MySQL

Query all databases

Show databases

Query all table names in the specified database

Select table_name from information_schema.tables where table_schema='database_name' and table_type='base table'

Query all field names in the specified table

Select column_name from information_schema.columns where table_schema='database_name' and table_name='table_name'

Query all field names and field types in the specified table

Select column_name,data_type from information_schema.columns where table_schema='database_name' and table_name='table_name'

Query all database and table names in SQLServer

Query all databases

Select * from sysdatabases

Query all table names in the current database

Select * from sysobjects where xtype='U';xtype='U': represents all user tables and xtype='S': represents all system tables.

Query all field names in the specified table

Select name from syscolumns where id=Object_Id ('table_name')

Query all field names and field types in the specified table

Select sc.name,st.name from syscolumns sc,systypes st where sc.xtype=st.xtype and sc.id in (select id from sysobjects where xtype='U' and name='table_name')

Query all database and table names in Oracle

Query all databases

Because Oralce has no library name, only table space, Oracle does not provide database name query support, only table space name query.

Select * from vested tablespace-query tablespace (certain permissions are required)

Query all table names in the current database

Select * from user_tables

Query all field names in the specified table

Select column_name from user_tab_columns where table_name = 'table_name';-- table name should be all uppercase

Query all field names and field types in the specified table

Select column_name, data_type from user_tab_columns where table_name = 'table_name';-

Use SQL statements to query all MySQL,SQLServer,Oracle database names and table names, field names of SQL statements, simple and clear

The above is all the contents of the article "how to use SQL statements to query all database names and table names and field names of MySQL,SQLServer,Oracle". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report