资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

mysql怎么查所有表名,mysql 查表名

解决mysql查询数据库所有的表名称和表结构的sql语句怎么写

查询MySQL数据库所有表名的SQL命令:

成都创新互联是一家专注于网站设计、成都网站设计与策划设计,山阳网站建设哪家好?成都创新互联做网站,专注于网站建设十年,网设计领域的专业建站公司;建站业务涵盖:山阳等地区。山阳做网站价格咨询:028-86922220

show tables;

查询MySQL数据库有表结构的SQL命令:

show create table tblName;

例如:show create table students;

CREATE TABLE `students` (

`sid` char(10) NOT NULL,

`sname` varchar(50) NOT NULL,

`sex` char(1) NOT NULL,

`dob` date NOT NULL,

`phone` varchar(30) DEFAULT NULL,

PRIMARY KEY (`sid`),

KEY `index_tbl1_url` (`phone`(20))

) ENGINE=InnoDB DEFAULT CHARSET=gb2312

怎样获取mysql数据库里所有表的名字

用sql获取数据库中所有的表名的方法:

1、oracle下:select table_name from all_tables;

2、MySQL下:select table_name from information_schema.tables where table_schema='csdb' and table_type='base table';

3、sql server下:select name from sys.tables go

mysql如何进入数据库查看所有表

1.查看数据库,选中使用数据库,并查看数据库表,具体操作命令如下:

show databases;

use student;

show tables;

2.选择student数据库中的一张表stu_score,查看数据库表数据,并利用explain分析数据库表,如下图所示:

select * from stu_score;

explain select * from stu_score;

3.查看数据库使用索引的情况,使用命令:

show status like 'Handler_read%';

4.用于分析和存储表的关键字,分析的结果可以得到精准的信息,利用命令analyze,

analyze table stu_score;

5.检查数据库表stu_score,检查表是否有错误,利用命令:

check table stu_score;

6.优化数据库表,利用命令:

optimize table stu_score;

扩展资料:

可以使用命令行工具管理 MySQL 数据库(命令 mysql 和 mysqladmin),也可以从 MySQL 的网站下载图形管理工具 MySQL Administrator, MySQL Query Browser 和 MySQL Workbench。

phpMyAdmin是由 php 写成的 MySQ L资料库系统管理程程序,让管理者可用 Web 界面管理 MySQL 资料库。

phpMyBackupPro也是由 PHP 写成的,可以透过 Web 界面创建和管理数据库。它可以创建伪 cronjobs,可以用来自动在某个时间或周期备份 MySQL 数据库。

另外,还有其他的 GUI 管理工具,例如 mysql-front 以及 ems mysql manager, navicat等等。

查询mysql数据库中所有表名

查找所有表的语句

select table_name

from information_schema.tables

where table_schema='当前数据库'

mysql  use mysql

Database changed

mysql show tables;

+---------------------------+

| Tables_in_mysql           |

+---------------------------+

| columns_priv              |

| db                        |

| event                     |

| func                      |

| general_log               |

| help_category             |

| help_keyword              |

| help_relation             |

| help_topic                |

| innodb_index_stats        |

| innodb_table_stats        |

| ndb_binlog_index          |

| plugin                    |

| proc                      |

| procs_priv                |

| proxies_priv              |

| servers                   |

| slave_master_info         |

| slave_relay_log_info      |

| slave_worker_info         |

| slow_log                  |

| tables_priv               |

| time_zone                 |

| time_zone_leap_second     |

| time_zone_name            |

| time_zone_transition      |

| time_zone_transition_type |

| user                      |

+---------------------------+

28 rows in set (0.05 sec)

show tables即为显示当前数据库中所有的表。

根据具体问题类型,进行步骤拆解/原因原理分析/内容拓展等。

具体步骤如下:/导致这种情况的原因主要是??

mysql里面查某个数据库的所有表名,语句该怎么写?不要什么show tables,因为那样会把视图也查出来!

TABLE 语句

具体语法:TABLE table_name [ORDER BY column_name] [LIMIT number [OFFSET number]]

其实从语法上看,可以排序,也可以过滤记录集,不过比较简单,没有 SELECT 那么强大。

示例 1

简单的建一张很小的表 y1,记录数为 10 条。表 t1,插入 10 条记录

mysql-(ytt/3305)-create table t1 (r1 int,r2 int);

Query OK, 0 rows affected (0.02 sec)

mysql-(ytt/3305)-insert into t1

with recursive aa(a,b) as (

select 1,1

union all

select a+1,ceil(rand()*20) from aa where a 10

) select * from aa;

Query OK, 10 rows affected (0.00 sec)

Records: 10  Duplicates: 0  Warnings: 0

简单全表扫描mysql-(ytt/3305)-select * from t1;+------+------+| r1   | r2   |+------+------+|    1 |    1 ||    2 |    9 ||    3 |    9 ||    4 |   17 ||    5 |   17 ||    6 |   16 ||    7 |    6 ||    8 |    1 ||    9 |   10 ||   10 |    3 |+------+------+10 rows in set (0.00 sec)

TABLE 结果mysql-(ytt/3305)-table t1;+------+------+| r1   | r2   |+------+------+|    1 |    1 ||    2 |    9 ||    3 |    9 ||    4 |   17 ||    5 |   17 ||    6 |   16 ||    7 |    6 ||    8 |    1 ||    9 |   10 ||   10 |    3 |+------+------+10 rows in set (0.00 sec)

看下 table 的执行计划mysql-(ytt/3305)-explain table t1 order by r1 limit 2\G*************************** 1. row ***************************           id: 1  select_type: SIMPLE        table: t1   partitions: NULL         type: ALLpossible_keys: NULL          key: NULL      key_len: NULL          ref: NULL         rows: 10     filtered: 100.00        Extra: Using filesort1 row in set, 1 warning (0.00 sec)

其实可以看到 TABLE 内部被 MySQL 转换为 SELECT 了。mysql-(ytt/3305)-show warnings\G*************************** 1. row ***************************  Level: Note   Code: 1003Message: /* select#1 */ select `ytt`.`t1`.`r1` AS `r1`,`ytt`.`t1`.`r2` AS `r2` from `ytt`.`t1` order by `ytt`.`t1`.`r1` limit 21 row in set (0.00 sec)

那其实从上面简单的例子可以看到 TABLE 在内部被转成了普通的 SELECT 来处理。示例 2应用于子查询里的子表。这里要注意,内表的字段数量必须和外表过滤的字段数量一致。克隆表 t1 结构mysql-(ytt/3305)-create table t2 like t1;Query OK, 0 rows affected (0.02 sec)

克隆表 t1 数据mysql-(ytt/3305)-insert into t2 table t1;Query OK, 10 rows affected (0.00 sec)Records: 10  Duplicates: 0  Warnings: 0

table t1 被当做内表,表 t1 有两个字段,必须同时满足 t2 检索时过滤的字段也是两个。mysql-(ytt/3305)-select * from t2 where (r1,r2) in (table t1);+------+------+| r1   | r2   |+------+------+|    1 |    1 ||    2 |    9 ||    3 |    9 ||    4 |   17 ||    5 |   17 ||    6 |   16 ||    7 |    6 ||    8 |    1 ||    9 |   10 ||   10 |    3 |+------+------+10 rows in set (0.00 sec)

注意:这里如果过滤的字段数量和子表数量不一致,则会报错。


标题名称:mysql怎么查所有表名,mysql 查表名
本文地址:http://cdkjz.cn/article/hcipdd.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220