解析如何查看Oracle数据库中某张表的字段个数

前端之家收集整理的这篇文章主要介绍了解析如何查看Oracle数据库中某张表的字段个数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Oracle中查询某个表的总字段数,要用sql语句,或者在PL/sql里面
<div class="codetitle"><a style="CURSOR: pointer" data="99470" class="copybut" id="copybut99470" onclick="doCopy('code99470')"> 代码如下:

<div class="codebody" id="code99470">
select count(column_name) from user_tab_columns where table_name='T_B_AUDITOR'

能够查出来指定的那张表的字段数。

下面是通过大致查看:

<FONT style="COLOR: #ff0000">select tname,count() from col group by tname;
<div class="codetitle"><a style="CURSOR: pointer" data="91184" class="copybut" id="copybut91184" onclick="doCopy('code91184')"> 代码如下:
<div class="codebody" id="code91184">
64T_A_BOOKSTAGEINFO4
65T_B_AUDITOR14
66T_B_BOOKMANAGEMENT13
67T_B_BOOKSTATUSCONFIG5
68T_B_CODETREEINFO8
69T_B_FILTERWORD11
70T_B_ISBNWHITELIST11
71T_B_MODEL10
72T_B_NOTICE15
73T_B_NOTICEACCEPT11
74T_B_OPERLOG10
75T_B_ORGANIZATIONINFO18
76T_B_PREFIXINFO15
77T_B_PUBLISHINFO30
78T_B_ROLE8
79T_B_ROLEMODEL6
80T_B_SAMPLEBOOKINFO89
81T_B_USER26
82T_B_USERANDROLE6
83T_B_USERLOGIN8
84T_B_USERMODEL6

此时我就联想到了MysqL上面去:

<FONT style="COLOR: #ff0000">直接利用函数解决

<div class="codetitle"><a style="CURSOR: pointer" data="69157" class="copybut" id="copybut69157" onclick="doCopy('code69157')"> 代码如下:
<div class="codebody" id="code69157">
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)

还有就是利用系统表:

<div class="codetitle"><a style="CURSOR: pointer" data="8678" class="copybut" id="copybut8678" onclick="doCopy('code8678')"> 代码如下:
<div class="codebody" id="code8678">
MysqL> use information_schema
Database changed
MysqL> select count(
) from columns where table_name="test";
+----------+
| count() |
+----------+
| 3 |
+----------+
1 row in set (0.00 sec)

MysqL中想要知道数据库中有多少个库:

<div class="codetitle"><a style="CURSOR: pointer" data="90116" class="copybut" id="copybut90116" onclick="doCopy('code90116')"> 代码如下:<div class="codebody" id="code90116">
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数据库中有多少张表:

<div class="codetitle"><a style="CURSOR: pointer" data="72362" class="copybut" id="copybut72362" onclick="doCopy('code72362')"> 代码如下:<div class="codebody" id="code72362">
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中大多的数据库,表啊都会有记录的。所以要好好研究下这张表呢。

数据库字段

猜你在找的Oracle相关文章