MySQL操作程序三十七(makers table增加 nation)
返回
作业内容
- 注意修改其他用到makersTABLE的地方?
- mscqtn_input.htm,不修改
- mscenq1.htm,仕入先检索,mscs_header.pl,不修改
mscenq1.htm,仕入先追加,mscshowadd2.pl,msc234.htm修改
mscenq1.pl,输入项目的改行符号删除
$string =~ s/\r//;
$string =~ s/\n//;
- msc233.htm修改
mscupdate.pl不修改
- msc232.htm修改
mscshowall.pl不修改
- mscdatabase.htm修改
mscshowall.pl不修改
msc231.htm修改
- makers的column增加
mysql> ALTER TABLE makers ADD nationid INT NOT NULL DEFAULT 2;==>OK
Query OK, 749 rows affected (0.22 sec)
Records: 749 Duplicates: 0 Warnings: 0
ALTER TABLE makers ADD nationid INT SET DEFAULT 2;==>NG
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 'SET D
EFAULT 2' at line 1
ALTER TABLE makers DROP nationid;
ALTER TABLE makers ALTER nationid SET DEFAULT 2;==>没有改变
mysql> insert into makers (nationid) values("2");==>只插入了一个!
Query OK, 1 row affected (0.08 sec)
mysql> show columns from makers;
+----------+-----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| company | char(100) | YES | | NULL | |
| address | char(100) | YES | | NULL | |
| person | char(50) | YES | | NULL | |
| telfax | char(100) | YES | | NULL | |
| email | char(100) | YES | | NULL | |
| homepage | char(100) | YES | | NULL | |
| memo | char(200) | YES | | NULL | |
| nationid | int(11) | YES | | NULL | |
+----------+-----------+------+-----+---------+----------------+
9 rows in set (0.02 sec)
ALTER TABLE makers ADD nationid INT AFTER memo;
mysql> show columns from makers;
+----------+-----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| company | char(100) | YES | | NULL | |
| address | char(100) | YES | | NULL | |
| person | char(50) | YES | | NULL | |
| telfax | char(100) | YES | | NULL | |
| email | char(100) | YES | | NULL | |
| homepage | char(100) | YES | | NULL | |
| memo | char(200) | YES | | NULL | |
+----------+-----------+------+-----+---------+----------------+
8 rows in set (0.24 sec)
返回