MySQL
- 1. Query all databases
show databases;
- 2. Query all table names in the specified database
use 数据库名
show tables;
or
select table_name from information_schema.tables where table_schema='数据库名' and table_type='BASE TABLE';
- 3. Query all field names in the specified table
select column_name from information_schema.columns where table_schema='数据库名' and table_name='表名';
- 4. Query all field names and field types in the specified table
show create table 表名;
or
select column_name,data_type from information_schema.columns where table_schema='数据库名' and table_name='表名';
SQLServer
- query all databases
select * from sysdatabases;
- Query all table names in the current database
select * from sysobjects where xtype='U';
xtype='U':表示所有用户表,xtype='S':表示所有系统表。
- 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');
Oracle
- Query all databases
Since Oralce has no database name, only table space, so Oracle does not provide database name query support, only provides table space name query.
select * from v$tablespace;--查询表空间(需要一定权限)
- 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';--表名要全大写
- 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';--表名要全大写