网上摘录整理了一下
-- 1. mysql存在相同key的则更新,不存在则插入
INSERT INTO t_member (id, name, email) VALUES
(1, 'nick', 'nick@126.com'),
(4, 'angel','angel@163.com')
ON DUPLICATE KEY UPDATE name=VALUES(name), email=VALUES(email);
-- 2. 查看mysql单次插入最大能容纳多少,以及修改
-- 查询最大容量:
show variables like 'max_allowed_packet';
-- 永久修改:在配置文件/etc/mysql/mysql.conf.d/mysqld.cnf 末尾加入一行max_allowed_packet = 256M
-- 临时修改:
set global max_allowed_packet = 2*1024*1024*10
-- 3.查看数据库数据大小,数据库中各表大小
use information_schema;
describe tables;
select table_name,table_rows,data_length+index_length,concat(round((data_length+index_length)/1024/1024,2),'MB') data from tables where table_schema='employees';
select table_name,table_rows,data_length+index_length,concat(round((data_length+index_length)/1024/1024,2),'MB') data from tables where table_schema='employees' and table_name='employees';