基础SQL语句,记录以备查阅。(在HeiDiSql中执行)

# 创建数据库
Create Database If Not Exists VerifyIdear Character Set UTF8;
# 创建表
Create Table If Not Exists VerifyIdear.MyTable(
    ID Bigint(8) unsigned Primary key Auto_Increment,
    Updatetime DateTime,
    name  VarChar(128)
)Engine = MyISAM;
# 切换到指定的数据库
use verifyidear; 

# 指定表增加字段
alter table MyTable add column If Not Exists adcolumn varchar(64) default '';
# 删除表中字段
alter table MyTable drop column If Exists adcolumn; 

 

#增加表注释
 alter table mytable comment '测试用表';

# 修改字段名称、类型、默认值、字段排序规则、注释、字段所处位置
ALTER TABLE `mytable` CHANGE COLUMN `name` `name` VARCHAR(128) DEFAULT NULL COLLATE 'utf8_general_ci' COMMENT '用户名' AFTER `thTime`;


#修改字段类型、默认值、排序规则、注释、字段位置
alter table mytable modify column name varchar(128) default null collate 'utf8_general_ci' comment '用户名' after thtime;

 

相关文章:

  • 2021-12-12
  • 2022-12-23
  • 2021-05-08
  • 2021-12-14
  • 2021-12-06
  • 2021-06-10
  • 2021-12-25
  • 2021-07-21
猜你喜欢
  • 2021-04-01
  • 2021-04-24
  • 2022-02-22
  • 2021-11-25
  • 2021-08-05
  • 2022-12-23
  • 2021-07-12
相关资源
相似解决方案