当前位置: 移动技术网 > IT编程>数据库>Mysql > Mysql 自动增加设定基值的语句

Mysql 自动增加设定基值的语句

2017年12月12日  | 移动技术网IT编程  | 我要评论
核心代码:
复制代码 代码如下:

alter table 表名 auto_increment = 设定的值

mysql alter语法中alter [ignore] table tbl_name alter_spec [, alter_spec ...]
复制代码 代码如下:

alter_specification:
add [column] create_definition [first | after column_name ]
or add index [index_name] (index_col_name,...)
or add primary key (index_col_name,...)
or add unique [index_name] (index_col_name,...)
or alter [column] col_name {set default literal | drop default}
or change [column] old_col_name create_definition
or modify [column] create_definition
or drop [column] col_name
or drop primary key
or drop index index_name
or rename [as] new_tbl_name
or table_options
eg:
mysql> alter table topics change hotico hot_count int(4);
mysql> alter table topics alter hot_count set default 1;

补充:
加索引
mysql> alter table 表名 add index 索引名 (字段名1[,字段名2 …]);

例子: mysql> alter table employee add index emp_name (name);
加主关键字的索引
mysql> alter table 表名 add primary key (字段名);
例子: mysql> alter table employee add primary key(id);
加唯一限制条件的索引
mysql> alter table 表名 add unique 索引名 (字段名);
例子: mysql> alter table employee add unique emp_name2(cardnumber);
mysql alter语法运用:查看某个表的索引
mysql> show index from 表名;

例子: mysql> show index from employee;

删除某个索引
mysql> alter table 表名 drop index 索引名;

例子: mysql>alter table employee drop index emp_name;

修改表:增加字段:mysql> alter table table_name add field_name field_type;
查看表:mysql> select * from table_name;

修改原字段名称及类型:mysql> alter table table_name change old_field_name new_field_name field_type;

删除字段:mysql alter table table_name drop field_name;

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网