修改表中一行或多行數據: SELECT*FROM student;+ + + +| id | name | ban |+ + + +| 1 | yy | 1913 || 7 | ss | 1923 || 8 | 許 | 1913 || 9 | 應 | 1913 || 10 | Aron | 1913 ...
修改表中一行或多行數據:
SELECT*FROM student;+----+------+------+
| id | name | ban |
+----+------+------+
| 1 | yy | 1913 |
| 7 | ss | 1923 |
| 8 | 許 | 1913 |
| 9 | 應 | 1913 |
| 10 | Aron | 1913 |
+----+------+------+
5 rows in set UPDATE student SET name="yiyq"WHERE ban=1913;
Query OK, 4 rows affected
Rows matched: 4 Changed: 4 Warnings: 0 檢查:SELECT*FROM student;
+----+------+------+
| id | name | ban |
+----+------+------+
| 1 | yiyq | 1913 |
| 7 | ss | 1923 |
| 8 | yiyq | 1913 |
| 9 | yiyq | 1913 |
| 10 | yiyq | 1913 |
+----+------+------+
5 rows in set 刪除數據:SELECT*FROM accout;
+----+------+-------+
| id | name | money |
+----+------+-------+
| 1 | a | 800 |
| 2 | b | 1200 |
+----+------+-------+
2 rows in set DELETE FROM accout WHERE name="a";
Query OK, 1 row affected SELECT*FROM accout;
+----+------+-------+
| id | name | money |
+----+------+-------+
| 2 | b | 1200 |
+----+------+-------+
1 row in set 創建表時創建索引: INDEX id; TRUNCATE也是刪除數據,但它是刪除一個表在重建一個相同的表。 創建索引: CREATE [UNIQUE/FULLTEXT/SPATIAL] INDEX 索引名 ON 表名 (欄位名 [(長度)] [ASC/DESC]); 普通索引什麼都不加, UNIQUE:可選參數,表示唯一約束, FULLTEXT:可選參數,表示全文約束 SPATIAL:可選參數,表示空間約束 用ALTER創建: ALTER TABLE 表名 ADD [UNIQUE/FULLTEXT/SPATIAL] INDEX 索引名(欄位名[(長度)] [ASC/DESC]); 普通索引:ALTER TABLE book ADD INDEX inter_id(bookid); 刪除索引: 1.ALTER TABLE 表名 DROP INDEX 欄位名; 2.DROP INDEX 索引名 ON 表名;