或者在PL/SQL里面复制代码 代码如下

时间:2020-02-16 17:08来源:快三在线投注平台数据库
Oracle中查询某个表的总字段数,要用SQL语句,或者在PL/SQL里面复制代码 代码如下:select count(column_name)from user_tab_columns wheretable_name='T_B_AUDITOR'能够查出来指定的那张表的字段数。 下面是通

Oracle中查询某个表的总字段数,要用SQL语句,或者在PL/SQL里面复制代码 代码如下:select count(column_name) from user_tab_columns where table_name='T_B_AUDITOR'能够查出来指定的那张表的字段数。下面是通过大致查看:select tname,count(*) from col group by tname;复制代码 代码如下:64T_A_BOOKSTAGEINFO465T_B_AUDITOR1466T_B_BOOKMANAGEMENT1367T_B_BOOKSTATUSCONFIG568T_B_CODETREEINFO869T_B_FILTERWORD1170T_B_ISBNWHITELIST1171T_B_MODEL1072T_B_NOTICE1573T_B_NOTICEACCEPT1174T_B_OPERLOG1075T_B_ORGANIZATIONINFO1876T_B_PREFIXINFO1577T_B_PUBLISHINFO3078T_B_ROLE879T_B_ROLEMODEL680T_B_SAMPLEBOOKINFO8981T_B_USER2682T_B_USERANDROLE683T_B_USERLOGIN884T_B_USERMODEL6此时我就联想到了mysql上面去: 直接利用函数来解决:复制代码 代码如下:mysql desc test;+---------+-------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+---------+-------------+------+-----+---------+----------------+| id | int(11) | NO | PRI | NULL | auto_increment || name | varchar(10) | YES | | NULL | || address | varchar(30) | YES | | NULL | |+---------+-------------+------+-----+---------+----------------+3 rows in set (0.01 sec)mysql select found_rows();+--------------+| found_rows() |+--------------+| 3 |+--------------+1 row in set (0.01 sec)还有就是利用系统表: 复制代码 代码如下:mysql use information_schemaDatabase changedmysql select count(*) from columns where table_name="test";+----------+| count(*) |+----------+| 3 |+----------+1 row in set (0.00 sec)在mysql中想要知道数据库中有多少个库: 复制代码 代码如下:mysql select * from schemata;+--------------+--------------------+----------------------------+------------------------+----------+| CATALOG_NAME | SCHEMA_NAME | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH |+--------------+--------------------+----------------------------+------------------------+----------+| NULL | information_schema | utf8 | utf8_general_ci | NULL || NULL | mysql | utf8 | utf8_general_ci | NULL || NULL | test | utf8 | utf8_general_ci | NULL |+--------------+--------------------+----------------------------+------------------------+----------+3 rows in set (0.00 sec)在mysql数据库中有多少张表: 复制代码 代码如下:mysql select table_schema,count(*) from tables group by table_schema;+--------------------+----------+| table_schema | count(*) |+--------------------+----------+| information_schema | 17 || mysql | 17 || test | 6 |+--------------------+----------+3 rows in set (0.00 sec)其实在系统表information_schema中大多的数据库,表啊都会有记录的。所以要好好研究下这张表呢。

编辑:快三在线投注平台数据库 本文来源:或者在PL/SQL里面复制代码 代码如下

关键词: