mysql语句

表结构

添加表字段:
alter table form_item ADD item tinyint;
添加字段注释:
ALTER TABLE form_item
 modify column Editable tinyint DEFAULT 0 comment '编辑是否可用: 0-可用, 1-不可用';

修改表名:
alter table oldname rename to newname;
修改列属性:
alter table tablename modify col varchar(20);
修改列名:
alter table tablename change oldcol newcol int;

删除列:
alter table tablename drop column col;

表数据

查看列:
desc tablename;
列出字段及详情:
SHOW FULL COLUMNS FROM resource_ext ;
SHOW FULL FIELDS FROM resource_ext;

修改字段数据:
update form_item set item =0;
设置字段默认值:
alter table form_item alter item set default '0';

数据字典SQL

-- 表结构  
SELECT  
    b.TABLE_COMMENT "表注释" ,  
    a.TABLE_NAME "表",   
    a.COLUMN_NAME "列",  
    CONCAT(a.COLUMN_COMMENT,a.COLUMN_KEY, a.EXTRA) "列注释",  
    a.COLUMN_TYPE "类型",       
    a.COLUMN_DEFAULT "默认值",   
    a.IS_NULLABLE "是否为空",   
    a.CHARACTER_SET_NAME "表字符集",  
    a.COLLATION_NAME  "校验字符集",  
    b.ENGINE "引擎"  
FROM information_schema.COLUMNS a,information_schema.TABLES b   
WHERE a.TABLE_SCHEMA=b.TABLE_SCHEMA   
AND a.TABLE_SCHEMA='marketing_activity'  
AND a.TABLE_NAME=b.TABLE_NAME
AND a.TABLE_NAME='form_item';  

你可能感兴趣的:(mysql语句)