那比如我上表中的id自增列能不能通过语句把AUTO_INCREMENT去掉,让它不是自增列,或者怎么能让自增列ID值增加到一定的数之后,我又让ID种子从1开始增加呢?
解决方案 »
- SQL分隔字符串问题,标题长,引起关注!~
- 我们写了一个sqlserver的分页存储过程,但是怎么样按照这种的根式,写一个mysql的分页存储过程!以前没有用过mysql,有谁知道怎么写啊?
- 求教!!id int primary key auto_increment是什么意思?
- 关于优化一个MYSQL中以诸个临时表索引字段连接在一起的多表联合SQL.
- mysql递归查询请教
- 请教三表inner join,取其中一个表的前2个记录的问题
- 求mysql 存储过程里,实现like
- mysql to mssql 导数据乱码问题
- select 居然出错
- mysql 游标只走一遍为什么
- 为什么我下载的mysql文件夹中没有bin文件夹
- 能不能将mysql数据库的varchar转换成int???
有些东西不是想当然的可以做到的,default 后面要使用常量,而不能使用函数或者表达式。
看看手册吧。
The DEFAULT clause specifies a default value for a column. With one exception, the default value must be a constant; it cannot be a function or an expression. This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE. The exception is that you can specify CURRENT_TIMESTAMP as the default for a TIMESTAMP column as of MySQL 4.1.2.
楼主是不是希望id成为这种样子?
1
2
3
1
2
3
……
如果是这样,不能用auto_increment,用alter table命令去掉它。
然后,这个字段你不能使用 primary key(auto_increment 用这个) 或者 unique 之类的唯一索引,否则,mysql是不允许你插入一样的记录(就是说你第二个“1”是无法添加到数据库中的)。
所以,这个字段的插入和判断应该要用程序来控制了。