- 论坛徽章:
- 8
|
原帖由 好看的附件 于 2009-7-16 17:51 发表
真的很奇怪啊!我就直接在命令行就这样,不过我alter table tbl_name auto_increment=1;就行了。是不是在创建表的时候auto_increment 要给初始值?
-bash-3.1# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> drop test_inc;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'test_inc' at line 1
mysql> drop table test_inc;
Query OK, 0 rows affected (0.00 sec)
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| userinfo |
+----------------+
1 row in set (0.00 sec)
mysql> create table test_inc (id int auto_increment primary key, name varchar(20));
Query OK, 0 rows affected (0.01 sec)
mysql> insert into test_inc(name) value('test1');
Query OK, 1 row affected (0.00 sec)
mysql> insert into test_inc(name) value('test2');
Query OK, 1 row affected (0.01 sec)
mysql> insert into test_inc(name) value('test3');
Query OK, 1 row affected (0.00 sec)
mysql> select * from test_inc;
+----+-------+
| id | name |
+----+-------+
| 1 | test1 |
| 2 | test2 |
| 3 | test3 |
+----+-------+
3 rows in set (0.00 sec)
mysql> truncate table test_inc;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into test_inc(name) value('test4');
Query OK, 1 row affected (0.00 sec)
mysql> select * from test_inc;
+----+-------+
| id | name |
+----+-------+
| 1 | test4 |
+----+-------+
1 row in set (0.00 sec)
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.0.45 |
+-----------+
1 row in set (0.00 sec)
mysql> |
|