bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

mysql數據庫基本命令---多條數據的同時操作


添加主鍵
MySQL> alter table info add primary key(id);
Query OK, 0 rows affected (0.07 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc info;  #查看主鍵
+--------+--------------+------+-----+---------+-------+
| Field  | Type         | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| id     | int(11)      | NO   | PRI | NULL    |       |    #顯示出主鍵
| name   | char(6)      | YES  |     | NULL    |       |
| score  | decimal(5,2) | YES  |     | NULL    |       |
| age    | int(4)       | YES  |     | NULL    |       |
| hobbly | int(4)       | YES  |     | NULL    |       |
+--------+--------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

添加外鍵
alter table info add constraint FK_ID foreign key(hobbly) REFERENCES hy(id);

mysql> show index from info\G;    #查看外鍵
* 2. row *
        Table: info
   Non_unique: 1
     Key_name: FK_ID     #外鍵添加成功
 Seq_in_index: 1
  Column_name: hobbly
    Collation: A
  Cardinality: 3
     Sub_part: NULL
       Packed: NULL
         Null: YES
   Index_type: BTREE
      Comment: 
Index_comment: 
2 rows in set (0.00 sec)

表格同時修改個字段(不同表列內容)
update info set age=23,num=44 where id=2;   
mysql> select * from info;
+----+--------+-------+-----------+------+------+
| id | name   | score | hobbly    | age  | num  |
+----+--------+-------+-----------+------+------+
|  1 | zl     | 88    | 看書      |   33 | NULL |
|  2 | 李四   | 68    | 上網      |   23 |   44 |        #成功修改
|  3 | 王四   | 68    | 看電視    | NULL | NULL |
+----+--------+-------+-----------+------+------+
3 rows in set (0.00 sec)

同時增加多個字段
mysql> alter table info add column age int,add column num int;
Query OK, 0 rows affected (0.05 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc info; #查看表結構
+--------+----------+------+-----+---------+-------+
| Field  | Type     | Null | Key | Default | Extra |
+--------+----------+------+-----+---------+-------+
| id     | int(11)  | NO   | PRI | NULL    |       |
| name   | char(4)  | YES  |     | NULL    |       |
| score  | char(6)  | YES  |     | NULL    |       |
| hobbly | char(10) | YES  |     | NULL    |       |
| age    | int(11)  | YES  |     | NULL    |       |
| num    | int(11)  | YES  |     | NULL    |       |
+--------+----------+------+-----+---------+-------+

同時刪除多個字段
mysql> alter table info drop column age,drop column num;
Query OK, 0 rows affected (0.05 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> select * from info;
+----+--------+-------+-----------+
| id | name   | score | hobbly    |
+----+--------+-------+-----------+
|  1 | zl     | 88    | 看書      |
|  2 | 李四   | 68    | 上網      |
|  3 | 王四   | 68    | 看電視    |
+----+--------+-------+-----------+

同時刪除多個記錄條數(多行)
mysql> delete from info where id in (3,4);
Query OK, 2 rows affected (0.00 sec)

mysql> select * from info;
+----+--------+-------+--------+
| id | name   | score | hobbly |
+----+--------+-------+--------+
|  1 | zl     | 88    | 看書   |
|  2 | 李四   | 68    | 上網   |
|  5 | kl     | 88    | 游泳   |
+----+--------+-------+--------+

同時查看多條指定記錄(行)
mysql> select * from info where id in (3,4);
+----+--------+-------+-----------+
| id | name   | score | hobbly    |
+----+--------+-------+-----------+
|  3 | 王四   | 68    | 看電視    |
|  4 | ll         | 67    | 看書      |
+----+--------+-------+-----------+

分享題目:mysql數據庫基本命令---多條數據的同時操作
瀏覽路徑:http://vcdvsql.cn/article26/iijecg.html

成都網站建設公司_創新互聯,為您提供網站設計公司微信小程序網站制作小程序開發關鍵詞優化

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

成都seo排名網站優化