mysql

2023-09-03  本文已影响0人  响呼雷
  1. 查询整个库占用多少内存
    select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data
    from information_schema.TABLES
    where table_schema = 'hz_safety_outside'
  2. 查询库种某张表占用多少内存
    select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data
    from information_schema.TABLES
    where table_schema = 'hz_safety_outside' and table_name='places'
  3. 增加字段(在特定的字段后增加)
    alter table 表名 add column 字段名 字段类型 afer 字段名(在哪个字段后增加)
    alter table dept Add column name varchar(20) not null default 0 AFTER sex;
    增加一个字段
    alter table places Add column country_value varchar(100) default null
    4.删除表字段
    alter table 表明 drop 字段名
    5.修改表名
    alter table 原表名 rename to 新表名;
    6.修改字段默认值
    ALTER TABLE 表名 ALTER COLUMN 字段名 SET DEFAULT 默认值
    7.修改类型
    ALTER TABLE 表名 MODIFY COLUMN 字段名 类型;
    8.备份表
    create table 备份表名 like 原表; 复制表结构
    insert into备份表名 select * from 原表; 复制表内容
上一篇 下一篇

猜你喜欢

热点阅读