浏览: 226
1、导出數據库為dbname的表结构(其中用戶名為root,密码為dbpasswd,生成的脚本名為db.sql)
mysqldump -uroot -pdbpasswd -d dbname >db.sql;
2、导出數據库為dbname某张表(test)结构
mysqldump -uroot -pdbpasswd -d dbname test>db.sql;
3、导出數據库為dbname所有表结构及表數據(不加-d)
mysqldump -uroot -pdbpasswd dbname >db.sql;
4、导出數據库為dbname某张表(test)结构及表數據(不加-d)
mysqldump -uroot -pdbpasswd dbname test>db.sql;
用SQL命令查看Mysql数据库大小
八月 20, 2011 ( 2 COMMENTS )
因为所管理的mysql数据库比较多,所以要想知道每个数据库的大小的话,在PhpMyAdmin中一个一个的查看太费时也费力。
今天知道了如何用SQL命令来查看mysql数据库大小,很是方便!!!
步骤如下:
1、进入 information_schema 数据库(存放了其他的数据库的信息)
use information_schema;
2、查询所有数据的大小:
SELECT concat(round(sum(DATA_LENGTH/1024/1024),2),’MB’) as data FROM TABLES;
3、查看指定数据库的大小:
比如查看数据库home的大小
SELECT concat(round(sum(DATA_LENGTH/1024/1024),2),’MB’) as data FROM TABLES WHERE table_schema=’home';
4、查看指定数据库的某个表的大小
比如查看数据库home中 members 表的大小
SELECT concat(round(sum(DATA_LENGTH/1024/1024),2),’MB’) as data FROM TABLES WHERE table_schema=’home’ AND table_name=’members';
大家可是试试哦:)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'9.91.161.3';
grant select on *.* to common_user@’%’
grant select,insert,update,delete on redmine1.* to jira@"%" identified by "jira";
ALTER TABLE table ADD [COLUMN] column_name column_definition [FIRST|AFTER existing_column];
alter table tb_active add constraint FK_ID foreign key(user_id) REFERENCES tb_user(id)
alter table 表名 add constraint FK_ID foreign key(你的外键字段名) REFERENCES 外表表名(对应的表的主键字段名);
1.添加PRIMARY KEY(主键索引)
mysql>ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` )
2.添加UNIQUE(唯一索引)
mysql>ALTER TABLE `table_name` ADD UNIQUE (
`column`
)
3.添加INDEX(普通索引)
mysql>ALTER TABLE `table_name` ADD INDEX index_name ( `column` )
4.添加FULLTEXT(全文索引)
mysql>ALTER TABLE `table_name` ADD FULLTEXT ( `column`)
5.添加多列索引
mysql>ALTER TABLE `table_name` ADD INDEX index_name ( `column1`, `column2`, `column3` )
SELECT tlvs1.set_id, tlvv1.vip, tlvs1.vport, tlvv1.vpcid
FROM tb_l7_vs_vips tlvv, tb_l7_virtual_service tlvs, tb_l7_virtual_service tlvs1, tb_l7_vs_vips tlvv1
WHERE tlvv1.vip = tlvv.vip AND tlvv1.vpcid = tlvv.vpcid
AND tlvs1.vport = tlvs.vport AND tlvv1.vsvc_id = tlvs1.id
AND tlvv.vsvc_id = tlvs.id AND tlvs.id IN
在这种查询非常耗计算量,往往出现
|
| 1548865788 | tgwoss | 9.199.10.163:41082 | tgwoss_apd | Query | 1 | Sending data | SELECT tlvs1.set_id, tlvv1.vip, tlvs1.vport, tlvv1.vpcid FROM tb_l7_vs_vips tlvv, tb_l7_virtual_serv |
| 1548865987 | tgwoss | 9.199.10.163:41140 | tgwoss_apd | Query | 1 | Sending data | SELECT tlvs1.set_id, tlvv1.vip, tlvs1.vport, tlvv1.vpcid FROM tb_l7_vs_vips tlvv, tb_l7_virtual_serv |
| 1548866087 | tgwoss | 9.199.10.163:41148 | tgwoss_apd | Query | 2 | Sending data | SELECT tlvs1.set_id, tlvv1.vip, tlvs1.vport, tlvv1.vpcid FROM tb_l7_vs_vips tlvv, tb_l7_virtual_serv |
sending data状态
原因是: tlvv1.vip = tlvv.vip AND tlvv1.vpcid = tlvv.vpcid
tb_l7_vs_vips 各自的 vip+vpcid 做了叉乘计算
如果出现 vip+vpcid 下关联vs规则非常多,则非常突出