fdhfgh 发表于 2017-12-12 06:35:02

MySQL中的表中增加删除字段

mysql> create table>
Query OK, 0 rows affected (0.13 sec)  

  

  
mysql
>>
Query OK, 0 rows affected (0.13 sec)  
Records:
0Duplicates: 0Warnings: 0  

  
mysql
> desc>
  

+---------+-------------+------+-----+---------+-------+  
| Field   | Type      | Null | Key | Default | Extra |
  
+---------+-------------+------+-----+---------+-------+

  
|>  
| name    | varchar(20) | YES|   | NULL    |       |
  
| age   | int(11)   | YES|   | NULL    |       |
  
| address | varchar(11) | YES|   | NULL    |       |
  
+---------+-------------+------+-----+---------+-------+
  
4 rows in set (0.00 sec)
  

  
2.删除两个字段

  
mysql>>  
Query OK, 0 rows affected (0.14 sec)
  
Records: 0Duplicates: 0Warnings: 0
  


  
mysql> desc>  
+-------+-------------+------+-----+---------+-------+
  
| Field | Type      | Null | Key | Default | Extra |
  
+-------+-------------+------+-----+---------+-------+

  
|>  
| name| varchar(20) | YES|   | NULL    |       |
  
+-------+-------------+------+-----+---------+-------+
  
2 rows in set (0.00 sec)
  

  
3.插入

  
mysql> insert into>  
Query OK, 1 row affected (0.00 sec)
  
4.查询看一下

  
mysql>>  
Query OK, 1 row affected (0.07 sec)
  
Records: 1Duplicates: 0Warnings: 0
  


  
mysql> select * from>  
+------+---------+------+---------+

  
|>  
+------+---------+------+---------+
  
|    1 | qustdjx | NULL | NULL    |
  
+------+---------+------+---------+
  
1 row in set (0.00 sec)
  
5.新增字段并插入

  
mysql> insert into>  
Query OK, 1 row affected (0.00 sec)
  


  
mysql> select * from>  
+------+---------+------+---------+

  
|>  
+------+---------+------+---------+
  
|    1 | qustdjx | NULL | NULL    |
  
|    2 | qust    |   14 | 山东    |
  
+------+---------+------+---------+
  
2 rows in set (0.00 sec)
  

  
页: [1]
查看完整版本: MySQL中的表中增加删除字段