1. 程式人生 > >引擎: 決定資料庫存取資料的方式 => 不同的特點 => 不同的使用者體驗 資料型別: 規定了資料庫可以存放哪些資料 約束: 限制儲存資料的規則 鍵

引擎: 決定資料庫存取資料的方式 => 不同的特點 => 不同的使用者體驗 資料型別: 規定了資料庫可以存放哪些資料 約束: 限制儲存資料的規則 鍵

Microsoft Windows [版本 10.0.17134.472]
(c) 2018 Microsoft Corporation。保留所有權利。

C:\Users\Administrator>SQL;
'SQL' 不是內部或外部命令,也不是可執行的程式
或批處理檔案。

C:\Users\Administrator>SQL
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.42 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> drop database db1;
Query OK, 6 rows affected (0.41 sec)

mysql> drop database db2;
Query OK, 1 row affected (0.19 sec)

mysql> drop database db3;
ERROR 1008 (HY000): Can't drop database 'db3'; database doesn't exist
mysql> create database db1;
Query OK, 1 row affected (0.00 sec)

mysql> use db1;
Database changed
mysql> create table t1(age int)engine=memory;
Query OK, 0 rows affected (0.08 sec)

mysql> show tables;
+---------------+
| Tables_in_db1 |
+---------------+
| t1 |
+---------------+
1 row in set (0.04 sec)

mysql> quit;
Bye

C:\Users\Administrator>sql
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.6.42 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show tables;
ERROR 1046 (3D000): No database selected
mysql> use db1;
Database changed
mysql> show tables;
+---------------+
| Tables_in_db1 |
+---------------+
| t1 |
+---------------+
1 row in set (0.00 sec)

mysql> show tables;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql> create table t1(name char)engine=innodb;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 1
Current database: db1

ERROR 1050 (42S01): Table 't1' already exists
mysql> desc ti;
ERROR 1146 (42S02): Table 'db1.ti' doesn't exist
mysql> desc t1;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| age | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.02 sec)

mysql> quit;
Bye

C:\Users\Administrator>sql
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.42 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use db1;
Database changed
mysql> show create t1;
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 't1' at line 1
mysql> show create table t1;
+-------+---------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------+
| t1 | CREATE TABLE `t1` (
`age` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=utf8 |
+-------+---------------------------------------------------------------------------------------+
1 row in set (0.03 sec)

mysql> create table t2(name char(5) not null)engine=innodb charset=utf8;
Query OK, 0 rows affected (0.29 sec)

mysql> create table t3(name char(5) )engine=innodb charset=utf8;
Query OK, 0 rows affected (0.38 sec)

mysql> insert into from t1 values('zzfsn');
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 'from t1 values('zzfsn')' at line 1
mysql> insert into t1 values('zzfsn');
Query OK, 1 row affected, 1 warning (0.05 sec)

mysql> insert into t1 values('');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> insert into t1 values(null);
Query OK, 1 row affected (0.00 sec)

mysql> insert into t2 values('');
Query OK, 1 row affected (0.08 sec)

mysql> insert into t2 values();
Query OK, 1 row affected, 1 warning (0.07 sec)

mysql> show create table t1;
+-------+---------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------+
| t1 | CREATE TABLE `t1` (
`age` int(11) DEFAULT NULL
) ENGINE=MEMORY DEFAULT CHARSET=utf8 |
+-------+---------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> show create table t2;
+-------+------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+------------------------------------------------------------------------------------+
| t2 | CREATE TABLE `t2` (
`name` char(5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+------------------------------------------------------------------------------------+
1 row in set (0.05 sec)

mysql> desc t2;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| name | char(5) | NO | | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.02 sec)

mysql> insert into t2 values();
Query OK, 1 row affected, 1 warning (0.08 sec)

mysql> insert into t2 name. values();
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 'name. values()' at line 1
mysql> insert into t2 name.values();
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 'name.values()' at line 1
mysql> insert into t3 name.values();
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 'name.values()' at line 1
mysql> insert into t2(name).values();
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 '.values()' at line 1
mysql> insert into t2 (name) values();
ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> insert into t3 (name) values();
ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> insert into t2 (name) values(null);
ERROR 1048 (23000): Column 'name' cannot be null
mysql> insert into t3 (name) values(null);
Query OK, 1 row affected (0.04 sec)

mysql> insert into t2 (name) values('rydtfugi');
Query OK, 1 row affected, 1 warning (0.08 sec)

mysql> desc t2;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| name | char(5) | NO | | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.02 sec)

mysql> select name from t2;
+-------+
| name |
+-------+
| |
| |
| |
| rydtf |
+-------+
4 rows in set (0.12 sec)

mysql> show variables like'%sql_mode%';
+---------------+------------------------+
| Variable_name | Value |
+---------------+------------------------+
| sql_mode | NO_ENGINE_SUBSTITUTION |
+---------------+------------------------+
1 row in set (0.00 sec)

mysql> show variables like '%sql_mode%';
+---------------+------------------------+
| Variable_name | Value |
+---------------+------------------------+
| sql_mode | NO_ENGINE_SUBSTITUTION |
+---------------+------------------------+
1 row in set (0.00 sec)

mysql> set global sql_mode='strict_trans_tables';
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t2 name values ('ryugiutyguh');
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 'name values ('ryugiutyguh')' at line 1
mysql> insert into t2 (name) values ('ryugiutyguh');
Query OK, 1 row affected, 1 warning (0.07 sec)

mysql> quit
Bye

C:\Users\Administrator>sql
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.42 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> insert into t2 (name) values ('ryyugiuhiougiutyguh');
ERROR 1046 (3D000): No database selected
mysql> use db1;
Database changed
mysql> insert into t2 (name) values ('ryyugiuhiougiutyguh');
ERROR 1406 (22001): Data too long for column 'name' at row 1
mysql> creat table t4;
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 'creat table t4' at line 1
mysql> create table t4(age int);
Query OK, 0 rows affected (0.28 sec)

mysql> insert into t4 values (5787);
Query OK, 1 row affected (0.07 sec)

mysql> creat table t5 (age int(4) zerofill);
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 'creat table t5 (age int(4) zerofill)' at line 1
mysql> creat table t5 (age int(4)) zerofill;
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 'creat table t5 (age int(4)) zerofill' at line 1
mysql> create table t5 (age int(4) zerofill);
Query OK, 0 rows affected (0.39 sec)

mysql> insert into t1 values (3546735467);
ERROR 1264 (22003): Out of range value for column 'age' at row 1
mysql> insert into t5 values (3546735467);
Query OK, 1 row affected (0.08 sec)

mysql> insert into t1 values (3);
Query OK, 1 row affected (0.00 sec)

mysql> insert into t5 values (3);
Query OK, 1 row affected (0.07 sec)

mysql> desc t5;
+-------+--------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------------------+------+-----+---------+-------+
| age | int(4) unsigned zerofill | YES | | NULL | |
+-------+--------------------------+------+-----+---------+-------+
1 row in set (0.02 sec)

mysql> select*from t5;
+------------+
| age |
+------------+
| 3546735467 |
| 0003 |
+------------+
2 rows in set (0.00 sec)

mysql> create table t6(age float);
Query OK, 0 rows affected (0.27 sec)

mysql> insert into t6 values(0.246354335555555555533333333333333);
Query OK, 1 row affected (0.08 sec)

mysql> select age from t6;
+----------+
| age |
+----------+
| 0.246354 |
+----------+
1 row in set (0.00 sec)

mysql> create table t7(age decimal);
Query OK, 0 rows affected (0.27 sec)

mysql> insert into t7 age values (1.22336564575674342223546);
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 'age values (1.22336564575674342223546)' at line 1
mysql> insert into t7 (age) values (1.22336564575674342223546);
Query OK, 1 row affected, 1 warning (0.07 sec)

mysql> select age from t7;
+------+
| age |
+------+
| 1 |
+------+
1 row in set (0.00 sec)

mysql> select*from t7;
+------+
| age |
+------+
| 1 |
+------+
1 row in set (0.00 sec)

mysql> create table t8(age decimal(65,30));
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 'decimal(65,30))' at line 1
mysql> create table t8(age decimal(65,30));
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 'decimal(65,30))' at line 1
mysql> create table t8(age decimal(65,30));
Query OK, 0 rows affected (0.25 sec)

mysql> select age from t8;
Empty set (0.00 sec)

mysql> insert into t8 values(7.46235744666666666);
Query OK, 1 row affected (0.07 sec)

mysql> select age from t8;
+----------------------------------+
| age |
+----------------------------------+
| 7.462357446666666660000000000000 |
+----------------------------------+
1 row in set (0.00 sec)

mysql> create table t9(x char(5),y varchar(5));
Query OK, 0 rows affected (0.25 sec)

mysql> insert into t9 (x,y)values('ftu','ytu');
Query OK, 1 row affected (0.07 sec)

mysql> select *from t9;
+------+------+
| x | y |
+------+------+
| ftu | ytu |
+------+------+
1 row in set (0.00 sec)

mysql> select char_length(x),char_length(y) from t9;
+----------------+----------------+
| char_length(x) | char_length(y) |
+----------------+----------------+
| 3 | 3 |
+----------------+----------------+
1 row in set (0.09 sec)

mysql> select global sql_mode='strict_tables,PAD_CHAR_TO_FULL_LENGTH';
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 '='strict_tables,PAD_CHAR_TO_FULL_LENGTH'' at line 1
mysql> set global sql_mode='strict_tables,PAD_CHAR_TO_FULL_LENGTH';
ERROR 1231 (42000): Variable 'sql_mode' can't be set to the value of 'strict_tables'
mysql> set global sql_mode='strict_trans_tables,PAD_CHAR_TO_FULL_LENGTH';
Query OK, 0 rows affected (0.00 sec)

mysql> select char_length(x),char_length(y) from t9;
+----------------+----------------+
| char_length(x) | char_length(y) |
+----------------+----------------+
| 3 | 3 |
+----------------+----------------+
1 row in set (0.00 sec)

mysql> quit;
Bye

C:\Users\Administrator>sql;
'sql' 不是內部或外部命令,也不是可執行的程式
或批處理檔案。

C:\Users\Administrator>sql
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.42 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select char_length(x),char_length(y) from t9;
ERROR 1046 (3D000): No database selected
mysql> use db1;
Database changed
mysql> select char_length(x),char_length(y) from t9;
+----------------+----------------+
| char_length(x) | char_length(y) |
+----------------+----------------+
| 5 | 3 |
+----------------+----------------+
1 row in set (0.00 sec)

mysql> create table t10(name enum('zzf','sn')not null default 'zf',hobbies set('basketball','pingpang','baseball');
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 '' at line 1
mysql> create table t10(name enum('zzf','sn')not null default 'zf',hobbies set('basketball','pingpang','baseball'));
ERROR 1067 (42000): Invalid default value for 'name'
mysql> create table t10(name enum('zzf','sn')not null default 'zzf',hobbies set('basketball','pingpang','baseball'));
Query OK, 0 rows affected (0.29 sec)

mysql> create table t11(my_datetime datetime, my_time time);
Query OK, 0 rows affected (0.27 sec)

mysql> insert into t11 values();
Query OK, 1 row affected (0.88 sec)

mysql> select*from t11;
+-------------+---------+
| my_datetime | my_time |
+-------------+---------+
| NULL | NULL |
+-------------+---------+
1 row in set (0.00 sec)

mysql> alter table t11 mondify my_time timestamp;
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 'mondify my_time timestamp' at line 1
mysql> alter table t11 mondify my_time timestamp;
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 'mondify my_time timestamp' at line 1
mysql> alter table t11 change my_time my_tim timestamp;
Query OK, 1 row affected (0.87 sec)
Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into t11(null,null);
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 'null,null)' at line 1
mysql> insert into t11 values(null,null);
Query OK, 1 row affected (0.08 sec)

mysql> select*from t11;
+-------------+---------------------+
| my_datetime | my_tim |
+-------------+---------------------+
| NULL | 2019-01-08 19:06:22 |
| NULL | 2019-01-08 19:08:17 |
+-------------+---------------------+
2 rows in set (0.00 sec)

mysql> insert into t11 values();
Query OK, 1 row affected (0.08 sec)

mysql> select *from t11;
+-------------+---------------------+
| my_datetime | my_tim |
+-------------+---------------------+
| NULL | 2019-01-08 19:06:22 |
| NULL | 2019-01-08 19:08:17 |
| NULL | 2019-01-08 19:09:21 |
+-------------+---------------------+
3 rows in set (0.00 sec)

mysql> create table t12(ip char(16), port int,unique(ip,port));
Query OK, 0 rows affected (0.36 sec)

mysql> insert into table t12 values('192.168.12.168',4646),('192.168.12.168',3563);
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 'table t12 values('192.168.12.168',4646),('192.168.12.168',3563)' at line 1
mysql> insert into table t12 values('192.168.12.168',4646);
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 'table t12 values('192.168.12.168',4646)' at line 1
mysql> insert into table t12 (ip,port) values('192.168.12.168',4646),('192.168.12.168',3563);
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 'table t12 (ip,port) values('192.168.12.168',4646),('192.168.12.168',3563)' at line 1
mysql> insert into table t12 (ip,port) values('192.168.12.168',4646);
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 'table t12 (ip,port) values('192.168.12.168',4646)' at line 1
mysql> insert into table t12 values('192.168.12.168',4646),('192.168.12.168',3563);
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 'table t12 values('192.168.12.168',4646),('192.168.12.168',3563)' at line 1
mysql> insert into t12 values('192.168.12.168',4646),('192.168.12.168',3563);
Query OK, 2 rows affected (0.06 sec)
Records: 2 Duplicates: 0 Warnings: 0

mysql> select*from t12;
+------------------+------+
| ip | port |
+------------------+------+
| 192.168.12.168 | 3563 |
| 192.168.12.168 | 4646 |
+------------------+------+
2 rows in set (0.03 sec)

mysql> create table t13(ip char(16),port int,unique port);
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 ')' at line 1
mysql> create table t13(ip char(16),port int,unique(port));
Query OK, 0 rows affected (0.32 sec)

mysql> insert into t13 values('192',56),('314',56);
ERROR 1062 (23000): Duplicate entry '56' for key 'port'
mysql> insert into t13 values('192',56),('314',57);
Query OK, 2 rows affected (0.08 sec)
Records: 2 Duplicates: 0 Warnings: 0

mysql> create table t14(ip char(16),port int primary key(ip,port));
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 '(ip,port))' at line 1
mysql> create table t14(ip char(16),port int, primary key(ip,port));
Query OK, 0 rows affected (0.34 sec)

mysql> select *from t13;
+------------------+------+
| ip | port |
+------------------+------+
| 192 | 56 |
| 314 | 57 |
+------------------+------+
2 rows in set (0.00 sec)

mysql> select *from t14;
Empty set (0.00 sec)

mysql> insert into t14 values('192',56),('314',56);
Query OK, 2 rows affected (0.06 sec)
Records: 2 Duplicates: 0 Warnings: 0

mysql> select *from t14;
+------------------+------+
| ip | port |
+------------------+------+
| 192 | 56 |
| 314 | 56 |
+------------------+------+
2 rows in set (0.00 sec)

mysql> desc t14;
+-------+----------+------+-----+------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+------------------+-------+
| ip | char(16) | NO | PRI | | |
| port | int(11) | NO | PRI | 0 | |
+-------+----------+------+-----+------------------+-------+
2 rows in set (0.02 sec)

mysql> desc t13;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| ip | char(16) | YES | | NULL | |
| port | int(11) | YES | UNI | NULL | |
+-------+----------+------+-----+---------+-------+
2 rows in set (0.02 sec)

mysql> create table t15(ip char(16),ip int,primary key(ip));
ERROR 1060 (42S21): Duplicate column name 'ip'
mysql> create table t15(ip char(16),ip int,primary key ip)
-> ;
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 ')' at line 1
mysql> create table t15 (ip char(16),ip int,primary key(port);)
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 '' at line 1
-> create table t15 (ip char(16),ip int,primary key(port));
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 ')
create table t15 (ip char(16),ip int,primary key(port))' at line 1
mysql> create table t15 (ip char(16),port int,primary key(port));
Query OK, 0 rows affected (0.29 sec)

mysql> inser into t15 values('6779',798),('6779',798);
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 'inser into t15 values('6779',798),('6779',798)' at line 1
mysql> insert into t15 values('6779',798),('6779',798);
ERROR 1062 (23000): Duplicate entry '798' for key 'PRIMARY'
mysql> insert into t15 values('6779',798),('6779',79);
Query OK, 2 rows affected (0.08 sec)
Records: 2 Duplicates: 0 Warnings: 0

mysql> select * from t14;
+------------------+------+
| ip | port |
+------------------+------+
| 192 | 56 |
| 314 | 56 |
+------------------+------+
2 rows in set (0.00 sec)

mysql> desc t14;
+-------+----------+------+-----+------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+------------------+-------+
| ip | char(16) | NO | PRI | | |
| port | int(11) | NO | PRI | 0 | |
+-------+----------+------+-----+------------------+-------+
2 rows in set (0.02 sec)

mysql> desc t15;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| ip | char(16) | YES | | NULL | |
| port | int(11) | NO | PRI | 0 | |
+-------+----------+------+-----+---------+-------+
2 rows in set (0.02 sec)

mysql> create table t16(id int,port int primary key auto_increment);
Query OK, 0 rows affected (0.34 sec)

mysql> insert into t16 values();
Query OK, 1 row affected (0.08 sec)

mysql> insert into t16 values();
Query OK, 1 row affected (0.08 sec)

mysql> insert into t16 values();
Query OK, 1 row affected (0.12 sec)

mysql> desc t16;
+-------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+----------------+
| id | int(11) | YES | | NULL | |
| port | int(11) | NO | PRI | NULL | auto_increment |
+-------+---------+------+-----+---------+----------------+
2 rows in set (0.02 sec)

mysql> select * from t16;
+------+------+
| id | port |
+------+------+
| NULL | 1 |
| NULL | 2 |
| NULL | 3 |
+------+------+
3 rows in set (0.00 sec)

mysql>