开发常用关系型数据库命令(长期更新)

查看一个表有多少字段:

MySQL:

select count(*) from information_schema.COLUMNS where TABLE_SCHEMA='数据库名称' and table_name='表名'

Oracle:

select count(*) from user_tab_columns t where t.TABLE_NAME='表名/视图名'


查看一个数据库下有多少张表:

MySQL:

SELECT COUNT(*) TABLES, table_schema FROM information_schema.TABLES   WHERE table_schema = '数据库名' GROUP BY table_schema;

Oracle:

SELECT count(*) FROM user_tables;


查看一张表所有字段:

MySQL:

select COLUMN_NAME,column_comment from INFORMATION_SCHEMA.Columns where table_name='表名' and table_schema='数据库名'  

Oracle:

select  *  from dba_tab_columns a where a.TABLE_NAME ='表名'




猜你喜欢

转载自blog.csdn.net/let_me_tell_you/article/details/80570203
今日推荐