数据库 
首页 > 数据库 > 浏览文章

使用SQL语句查询MySQL,SQLServer,Oracle所有数据库名和表名,字段名

(编辑:jimmy 日期: 2024/5/2 浏览:3 次 )

MySQL中查询所有数据库名和表名

查询所有数据库

show databases;


查询指定数据库中所有表名

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


查询指定表中的所有字段名

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


查询指定表中的所有字段名和字段类型

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


SQLServer中查询所有数据库名和表名

查询所有数据库

select * from sysdatabases;


查询当前数据库中所有表名

select * from sysobjects where xtype='U';
xtype='U':表示所有用户表,xtype='S':表示所有系统表。


查询指定表中的所有字段名

select name from syscolumns where id=Object_Id('table_name');


查询指定表中的所有字段名和字段类型

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中查询所有数据库名和表名

查询所有数据库

由于Oralce没有库名,只有表空间,所以Oracle没有提供数据库名称查询支持,只提供了表空间名称查询。

select * from v$tablespace;--查询表空间(需要一定权限)


查询当前数据库中所有表名

select * from user_tables;


查询指定表中的所有字段名

select column_name from user_tab_columns where table_name = 'table_name';--表名要全大写


查询指定表中的所有字段名和字段类型

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

使用SQL语句查询MySQL,SQLServer,Oracle所有数据库名和表名,字段名的SQL语句,简单明了

上一篇:200行代码轻松实现一个简单的区块链
下一篇:你应该知道的States字段使用规范
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网