Home 查询数据库所有表的所有字段
Post
Cancel

查询数据库所有表的所有字段

MySQL数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
SELECT
 table_name,
 column_name
FROM
 information_schema. COLUMNS
WHERE
 table_schema = 'testdb'
AND table_name IN (
 SELECT
  TABLE_NAME
 FROM
  INFORMATION_SCHEMA. TABLES
 WHERE
  TABLE_SCHEMA = 'testdb'
)
ORDER BY
 table_name,
 column_name

Oracle数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
SELECT
 A .table_name,
 A .COLUMN_NAME
FROM
 user_tab_columns A
WHERE
 TABLE_NAME IN (
  SELECT
   table_name
  FROM
   user_tables
 )
ORDER BY
 A .table_name

SQLServer数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
SELECT
 table_name,
 column_name
FROM
 information_schema.columns
WHERE
 table_name IN (
  SELECT
   TOP 100 PERCENT name
  FROM
   sysobjects
  WHERE
   xtype = 'u'
 )
ORDER BY
 table_name
This post is licensed under CC BY 4.0 by the author.