-
2022-04-01 16:08:44
查询数据库中的所有表格信息:
SELECT table_name, table_comment, create_time, update_time FROM information_schema.tables
WHERE table_schema = (SELECT DATABASE())
ORDER BY create_time DESC查询某个表格某一列的信息:
SELECT column_name, (CASE WHEN (is_nullable = 'no' && column_key != 'PRI') THEN '1' ELSE NULL END) AS is_required,
(CASE WHEN column_key = 'PRI' THEN '1' ELSE '0' END) AS is_pk, ordinal_position AS sort, column_comment,
(CASE WHEN extra = 'auto_increment' THEN '1' ELSE '0' END) AS is_increment, column_type
FROM information_schema.columns WHERE table_schema = (SELECT DATABASE()) AND table_name = ('sys_config')
ORDER BY ordinal_position更多相关内容 -
mysql如何查询所有表和字段信息
2021-01-27 22:01:11mysql查询所有表和字段信息的方法:1、根据库名获取所有表的信息SELECT*FROMinformation_schema.`TABLES`WHERETABLE_SCHEMA = 'erp';2、根据库名获取所有表名称和表说明SELECTTABLE_NAME,TABLE_...mysql查询所有表和字段信息的方法:
1、根据库名获取所有表的信息
SELECT
*
FROM
information_schema.`TABLES`
WHERE
TABLE_SCHEMA = 'erp';
2、根据库名获取所有表名称和表说明
SELECT
TABLE_NAME,
TABLE_COMMENT
FROM
information_schema.`TABLES`
WHERE
TABLE_SCHEMA = 'erp';
view:
3、根据库名获取所有的字段信息
SELECT
TABLE_SCHEMA AS '库名',
TABLE_NAME AS '表名',
COLUMN_NAME AS '列名',
ORDINAL_POSITION AS '列的排列顺序',
COLUMN_DEFAULT AS '默认值',
IS_NULLABLE AS '是否为空',
DATA_TYPE AS '数据类型',
CHARACTER_MAXIMUM_LENGTH AS '字符最大长度',
NUMERIC_PRECISION AS '数值精度(最大位数)',
NUMERIC_SCALE AS '小数精度',
COLUMN_TYPE AS 列类型,
COLUMN_KEY 'KEY',
EXTRA AS '额外说明',
COLUMN_COMMENT AS '注释'
FROM
information_schema.`COLUMNS`
WHERE
TABLE_SCHEMA = 'erp'
ORDER BY
TABLE_NAME,
ORDINAL_POSITION;
view:
4、根据库名获取所有的库和表字段的基本信息
SELECT
C.TABLE_SCHEMA AS '库名',
T.TABLE_NAME AS '表名',
T.TABLE_COMMENT AS '表注释',
C.COLUMN_NAME AS '列名',
C.COLUMN_COMMENT AS '列注释',
C.ORDINAL_POSITION AS '列的排列顺序',
C.COLUMN_DEFAULT AS '默认值',
C.IS_NULLABLE AS '是否为空',
C.DATA_TYPE AS '数据类型',
C.CHARACTER_MAXIMUM_LENGTH AS '字符最大长度',
C.NUMERIC_PRECISION AS '数值精度(最大位数)',
C.NUMERIC_SCALE AS '小数精度',
C.COLUMN_TYPE AS 列类型,
C.COLUMN_KEY 'KEY',
C.EXTRA AS '额外说明'
FROM
information_schema.`TABLES` T
LEFT JOIN information_schema.`COLUMNS` C ON T.TABLE_NAME = C.TABLE_NAME
AND T.TABLE_SCHEMA = C.TABLE_SCHEMA
WHERE
T.TABLE_SCHEMA = 'erp'
ORDER BY
C.TABLE_NAME,
C.ORDINAL_POSITION;
view:
-
mysql 查询表 所有字段
2022-01-07 19:36:36mysql 查询表 所有字段 select COLUMN_NAME,column_comment from information_schema.COLUMNS where table_name = 'db_car_apply' -- 查询表字段 select COLUMN_NAME from ...-- 查询所有字段, 含约束 SHOW FULL复制表结构
CREATE TABLE tb_students_copy LIKE tb_students_info;
查询mysql所有表数据、字段信息
mysql 查询表 所有字段
前2种有重复select COLUMN_NAME,column_comment from information_schema.COLUMNS where table_name = 'db_car_apply' -- 查询表字段 select COLUMN_NAME from information_schema.COLUMNS where table_name = '表名' and table_schema = '数据库名'; -- 查询所有字段, 含约束 SHOW FULL COLUMNS FROM 表名
MySQL中的备份和恢复
加了–single-transaction就能保证innodb的数据是完全一致的,而myisam引擎无法保证,必须加–lock-all-tables
–single-transaction参数的作用,设置事务的隔离级别为可重复读,即REPEATABLE READ,这样能保证在一个事务中所有相同的查询读取到同样的数据,也就大概保证了在dump期间,如果其他innodb引擎的线程修改了表的数据并提交,对该dump线程的数据并无影响
深入理解mysqldump原理 --single-transaction --lock-all-tables --master-data
以下命令不支持powershell(idea系列控制台也是), 支持cmd- 备份所有数据库
mysqldump -uroot -p --all-database > all.sql mysqldump -h localhost -P3306 -uroot -p123456 --single-transaction data docid > F:\docid.sql mysqlcmd = "/usr/bin/mysqldump -h " + HOST + " -P" + PORT + " -u" + USER + " -p" + PWD + \ " --single-transaction " + DB + " " + TABLE + " > " + db_backup_dir + "/" + backup_file_name
- 完全恢复
mysqldump的恢复也很简单,将备份作为输入执行即可,具体语法如下:
mysql -h localhost -P3306 -uroot -p123456 data < F:\docid.sql restorecmd = "/usr/bin/mysql -h " + HOST + " -P" + PORT + " -u" + USER + " -p" + PWD + " " + \ DB + " < " + db_backup_dir + "/" + backup_file_name
注意,将备份恢复后数据并不完整,还需要将备份后执行的日志进行重做,语法如下:
mysqlbinlog binlog-file | mysql -uroot -p
-
MySQL查询所有表名称和表注释
2020-01-13 21:45:34select table_name,table_comment from information_schema.tables where table_schema='数据库名称'select table_name,table_comment from information_schema.tables where table_schema='数据库名称'
-
MySQL查询数据库所有数据表数据条数
2021-10-29 11:02:19MySQL查询数据库所有数据表数据条数 select table_name,table_rows from information_schema.tables where TABLE_SCHEMA = ‘数据库名称’ order by table_rows desc; -
mysql查询数据中所有表
2020-03-04 09:59:021) 查询数据库中所有的表:数据库为:mfdb SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='mfdb' and table_name not like '%copy' 2) 显示所有的数据库: show databases ... -
MySQL统计数据库所有表的数据量
2021-12-13 14:00:52mysql统计一个数据库里所有表的数据量,最近在做统计想查找一个数据库里基本所有的表数据量,数据量少的通过select count再加起来也是可以的,不过表的数据有点多,有什么快捷的方法? -
mysql 查询每张表的数据量
2022-01-26 10:55:18#数据库中所有表的信息 SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '数据库名' #数据库中每个表的数据量 SELECT table_name,table_rows FROM information_schema.tables WHERE TABLE_SCHEMA = '... -
MySQL查询数据库所有表名及其注释
2022-04-12 09:46:521、查看Mysql 数据库 "ori_data"下所有表的表名、表注释及其数据量 SELECT TABLE_NAME 表名,TABLE_COMMENT 表注释,TABLE_ROWS 数据量 FROM information_schema.tables WHERE TABLE_SCHEMA = 'ori_data' ORDER BY ... -
MYSQL查询表数据量
2020-11-25 10:21:571.最常用的 SELECT COUNT(*) FROM 表名; 查的准确,但是数据量大的话(超过100万),比较慢。 2.网上找了一种,据说比count(*)快...3.查询当前库所有表数据量 SELECT TABLE_NAME,TABLE_ROWS FROM information_schema. -
Mysql 查看所有表的记录数
2021-05-28 15:02:20想快速的知道数据库中所有表的记录数信息怎么办?如果使用mysql的版本在5.0及以上,可以通过查询information_schema库中的tables表来获取,该表中使用table_rows记录表的行数信息。例如查看库sinaif_market中所有表... -
mysql 查询数据库所有表行数(数据条数)
2019-01-30 09:49:12mysql 查询数据库所有表行数(数据条数) 语句: use information_schema; select table_name,table_rows from tables where TABLE_SCHEMA = 'kdum_zh_test' order by table_rows desc; ... -
MySQL获取所有表及表结构
2021-02-20 18:37:381、获取所有表属性,语句如下: select table_name tableName, engine, table_comment tableComment, table_collation tableCollation, create_time createTime from information_schema.tables where ... -
查询MySQL中所有存在外键的表
2020-11-25 17:50:36一、查询系统中所有数据库下,所有存在外键的表 select * from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where REFERENCED_TABLE_NAME != "" 二、查询系统中某一个数据库下所有存在外键的表 select * from ... -
mysql查询所有数据库、表、字段常用sql语句
2019-01-15 22:26:47查询所有数据库名称: SELECT `SCHEMA_NAME` FROM `information_schema`.`SCHEMATA` 查询特定数据库下的所有表 //查询lml数据库下的所有表 select table_name from information_schema.tables ... -
MySQL查询数据库所有表名和描述
2020-11-26 10:56:35SELECT TABLE_NAME 表名, TABLE_COMMENT 描述 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = '数据库名' ...也可以直接在information_schema库的TABLES表里面查看 -
Mysql查看所有表的数据量
2019-12-27 11:48:45##查看所有表信息 SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '数据库名称'; ##查看各个表数据量 SELECT table_name,table_rows FROM information_schema.tables WHERE TABLE_SCHEMA = 'ehcore... -
查看Mysql 数据库所有表的数据量
2020-06-05 19:13:20##查看所有表信息 SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '数据库名称' \G; 2. ##查看各个表数据量 SELECT table_name,table_rows FROM information_schema.tables WHERE TABLE_SCHEMA... -
查询数据库中所有表名,查询表中所有字段名
2021-02-11 04:31:37查询数据库中所有表名称:select table_name from information_schema.tables where table_schema='数据库名称';(包含视图)select table_name from information_schema.tables where table_schema='数据库名称' and ... -
mysql中查看数据库中所有表的记录数
2021-01-18 18:48:59如果使用mysql的版本在5.0及以上,可以通过查询information_...例如查看库testdb中所有表的记录数:代码如下复制代码use information_schema;select table_name,table_rows from tableswhere TABLE_SCHEMA = 'testd... -
mysql如何进入数据库查看所有表
2019-09-03 17:09:31use mysql; show tables; 2.查看数据库表数据,并利用explain分析数据库表 select * from user; explain select * from user; 3.查看数据库使用索引的情况,使用命令: show status like ‘Handler_... -
mysql 查询所有库中所有表 表中大概记录数
2018-05-27 14:18:27查询数据库中所有表名表中数据量(不可靠:与数据库所用引擎有关) select table_name,table_rows from information_schema.tables where table_schema='databasename' order by table_rows desc; ; ... -
MySQL 查询表的所有列名
2021-11-25 10:28:32查询某个数据库中某个表的所有列: SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'db_name' AND TABLE_NAME = 'tb_name'; 查询某个数据库中某个表的所有列名,并用逗号连接: SELECT ... -
mysql查询所有表,并修改表字符集
2018-09-05 23:14:421.查询所有表 ALTER TABLE tbl_name CONVERT TO CHARACTER SET charset_name; 2.拼接sql select concat('ALTER TABLE ',table_name,' CONVERT TO CHARACTER SET utf8;') from information_schema.tables where ... -
【Mysql】如何查询数据库中存在某一个字段的所有表?
2021-10-15 08:42:30数据库里的表很多,一时之间忘记了要找的表,只记得其中的某些字段,可以用下面的sql来查询在这个数据库中,存在这个字段的所有表,是不是就缩小查找范围了呢? -- 注释: columnName 字段名 dbName 数据库名 -- ... -
查看mysql表中的所有索引
2020-12-28 13:29:55mysql查看所有表的索引: SELECT a.TABLE_SCHEMA, a.TABLE_NAME, a.index_name, GROUP_CONCAT(column_name ORDER BY seq_in_index) AS `Columns` FROM information_schema.statistics a GROUP BY a.TABLE_SCHEMA,a.... -
MySQL 数据表查询
2022-03-31 14:12:39查询数据指从数据库中获取所需要的数据。查询数据是数据库操作中最常用,也是最重要的操作。用户可以根据自己对数据的需求,...1.1、MySQL查询所有字段 查询所有字段 MySQL命令: select * from students; 1.2、MyS -
Mysql 查询所有表的行数和大小
2014-08-21 13:38:36Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 36 Server version: 5.6.16 MySQL Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All...