View the number of fields in a table in the database

Source: Internet
Author: User

View the number of fields in a table in the database. query the total number of fields in a table in Oracle. Use an SQL statement or [html] select count (column_name) in PL/SQL) from user_tab_columns where table_name = 't_ B _auditor 'can be used to check the number of fields in the specified table.
The following is a rough view: select tname, count (*) from col group by tname; [html] Listen 64 limit 4 65 T_ B _AUDITOR 14 66 T_ B _BOOKMANAGEMENT 13 67 T_ B _BOOKSTATUSCONFIG 5 68 limit 8 69 T_ B _FILTERWORD 11 70 limit 11 71 T_ B _MODEL 10 72 T_ B _NOTICE 15 73 limit 11 74 T_ B _OPERLOG 10 75 T_ B _ORGANIZATIONINFO 18 76 T_ B _PREFIXINFO 15 77 T_ B _PUBLISHINFO 30 78 T_ B _ROLE 8 79 T_ B _R OLEMODEL 6 80 T_ B _SAMPLEBOOKINFO 89 81 T_ B _USER 26 82 T_ B _USERANDROLE 6 83 T_ B _USERLOGIN 8 84 T_ B _USERMODEL 6 now I think of mysql above: using functions directly to solve: [html] 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) there is also the use of the system table: [html] mysql> use information_schema Database changed www.2cto.com mysql> select count (*) from col Umns where table_name = "test"; + ---------- + | count (*) | + ---------- + | 3 | + ---------- + 1 row in set (0.00 sec) in mysql, you want to know the number of databases in the database: [html] mysql> select * from schemata; + -------------- + ------------------ + upper + ---------- + | CATALOG_NAME | SCHEMA_NAME | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL _PATH | + --------------- ----- + Keys + ---------- + | NULL | information_schema | utf8 | utf8_general_ci | NULL | mysql | utf8 | utf8_general_ci | NULL | test | utf8 | utf8_general_ci | NULL | + -------------- + -------------------- + ------------------------------ + ------------------------ + ---------- + 3 rows in set (0.00 sec) the number of tables in the mysql database: [html] mysql> select table _ Schema, count (*) from tables group by table_schema; + -------------------- + ---------- + www.2cto.com | table_schema | count (*) | + -------------------- + ---------- + | information_schema | 17 | mysql | 17 | test | 6 | + -------------------- + ---------- + 3 rows in set (0.00 sec) in fact, most databases and tables in the system table information_schema will have records. So study this table. Author: chen861201

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.