MySql 怎样修改某字段的属性?使其不自动增长??
解决方案 »
- 谁知道这是什么问题?
- 请大家帮忙看看,使用mysql connector/c++ 往数据库中插入blob字段出1210错
- 奇怪的MySQL server has gone away。
- mysql查询问题,在线等
- How to replicate a table on the master server?
- MySQL创建表出错了,列类型可能定义的不对,大家帮忙看看
- 授权用户从远程登陆问题.
- 请问如用MySql 的C api 编程,能否将其结果绑定到一个表格控件中,能否用表格控件对数据库中的表进行各程操作?
- Can't connect to MySQL server on 'localhost' (10048) 错误
- C++调用含输出参数的存储过程
- 请教以下代码那里有问题,谢谢!!
- mysql 的BUG..看看谁有办法解决?
-> id int not null primary key auto_increment,
-> c1 int
-> );
Query OK, 0 rows affected (0.13 sec)mysql>
mysql> insert into tx values (null,11);
Query OK, 1 row affected (0.01 sec)mysql> insert into tx values (null,22);
Query OK, 1 row affected (0.05 sec)mysql> select * from tx;
+----+------+
| id | c1 |
+----+------+
| 1 | 11 |
| 2 | 22 |
+----+------+
2 rows in set (0.00 sec)mysql> alter table tx modify id int not null ;
Query OK, 2 rows affected (0.42 sec)
Records: 2 Duplicates: 0 Warnings: 0mysql> show create table tx \G
*************************** 1. row ***************************
Table: tx
Create Table: CREATE TABLE `tx` (
`id` int(11) NOT NULL,
`c1` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)mysql> select * from tx;
+----+------+
| id | c1 |
+----+------+
| 1 | 11 |
| 2 | 22 |
+----+------+
2 rows in set (0.00 sec)mysql> insert into tx values (null,33);
ERROR 1048 (23000): Column 'id' cannot be null
mysql> insert into tx values (3,33);
Query OK, 1 row affected (0.06 sec)mysql> select * from tx;
+----+------+
| id | c1 |
+----+------+
| 1 | 11 |
| 2 | 22 |
| 3 | 33 |
+----+------+
3 rows in set (0.00 sec)
+-------+-----------------------------------------------------------------------
--------------------------------------------------------------------------------
------------------------------------------------+
| Table | Create Table |
+-------+-----------------------------------------------------------------------
--------------------------------------------------------------------------------
------------------------------------------------+
| a | CREATE TABLE `a` (
`id` int(255) NOT NULL AUTO_INCREMENT,
`titile` varchar(255) NOT NULL,
`num` int(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 |
+-------+-----------------------------------------------------------------------
--------------------------------------------------------------------------------
------------------------------------------------+
1 row in set (0.03 sec)mysql> select * from a;
+----+--------+-----+
| id | titile | num |
+----+--------+-----+
| 1 | aa | 4 |
| 2 | pp | 2 |
| 3 | ii | 2 |
+----+--------+-----+
3 rows in set (0.02 sec)mysql> alter table a modify column id int not null;
Query OK, 3 rows affected (0.19 sec)
Records: 3 Duplicates: 0 Warnings: 0mysql> select * from a;
+----+--------+-----+
| id | titile | num |
+----+--------+-----+
| 1 | aa | 4 |
| 2 | pp | 2 |
| 3 | ii | 2 |
+----+--------+-----+
3 rows in set (0.02 sec)mysql> insert into a(titile,num) values('aaa',23);
Query OK, 1 row affected, 1 warning (0.05 sec)mysql> select * from a;
+----+--------+-----+
| id | titile | num |
+----+--------+-----+
| 0 | aaa | 23 |
| 1 | aa | 4 |
| 2 | pp | 2 |
| 3 | ii | 2 |
+----+--------+-----+
4 rows in set (0.00 sec)