增加字段:
ALTER TABLE table_name ADD field_name field_type;
修改原字段名称及类型:
ALTER TABLE table_name CHANGE old_field_name new_field_name field_type;
删除字段:
ALTER TABLE table_name DROP field_name
举例
修改为自增
alter table tb_name modify id int auto_increment primary key
修改字段默认值
alter table tablename alter column drop default; (若本身存在默认值,则先删除)
alter table tablename alter column set default 't5';(若本身不存在则可以直接设定)
增加主键
alter table tabelname add new_field_id int(5) unsigned default 0 not null auto_increment ,add primary key (new_field_id);
增加一个新列
alter table t2 add d timestamp;
alter table infos add ex tinyint not null default '0';
删除列
alter table t2 drop column c;
重命名列
alter table t1 change a b integer;
改变列的类型
alter table t1 change b b bigint not null;
alter table infos change list list tinyint not null default '0';
重命名表
alter table t1 rename t2;
加索引
alter table tablename add index 索引名 (字段名1[,字段名2 …]);
alter table tablename add index emp_name (name);
加主关键字的索引
alter table tablename add primary key(id);
加唯一限制条件的索引
alter table tablename add unique emp_name2(cardnumber);
删除某个索引5
alter table tablename drop index emp_name;
使用SQL语句 用...代替过长的字符串显示 语法: SQL数据库:select case when ...('@error_database_name',repair_allow_data_loss) alter database [@error_...
Mysql问题及SQL语句的使用_IT/计算机_专业资料。自己总结的一些基于mysql的关羽SQL...2.22.6 更新表结构 alter alter table tb_stu add address varchar(200); ...
[CONSTRAINT index] ALTER TABLE table ADD CONSTRAINT multifieldindex ALTER TABLE...mysql alter 语句用法,添... 2页 免费 sql_alter 2页 免费 数据库原理实验...
mysql语句总结 20页 免费 MySQL 经典语句总结 6页 免费 mysql必会操作语句总结...MySQL之alter语句用法总结MySQL之alter语句用法总结隐藏>> 苏州市凯康机械设备有限...
SQL语句详解:MySQL update的正确用法_IT/计算机_专业资料。SQL语句-update的使用说明。本文来自ChinaUnix网【IT168 技术】以下的文章主要介绍的是 MySQL update 语句...
SQL 分类: DDL—数据定义语言(Create,Alter,Drop,DECLARE) DML—数据操纵语言(...根据已有的表创建新表: A:create table tab_new like tab_old (使用旧表...
使用 SQL 语句 用...代替过长的字符串显示 语法: SQL 数据库:select case ...把 INTEGER 类型的列的名称从 old_name 变更到 new_name mysql> ALTER TABLE...
自己收集了一些非常经典的mysql语句大全。非常经典值得收藏,可以当mysql字典使用。...数据库/数据表/数据列权限: ALTER: 修改已存在的数据表(例如增加/删除列)和...
ORACLE 数据库的嵌入 SQL 语言 ORACLE 数据库的嵌入 SQL 1.)ORACLE 使用宿主...Oracle数据库SQL语句大全... 16页 免费 SQL语句MSSQL.MySQL.Ora... 13页 免费...
MYSQL查询语句的经典操作(图)_IT/计算机_专业资料。MySql数据库的操作及其常用语句数据库 SQL 语句的操作 1. DDL alter drop creat针对于结构 2. DCL grant comm...
热门文档