Modifying one or more rows of data in Table:
SELECT*FROM student;
+----+------+------+
| id | name | ban |
+----+------+------+
| 1 | yy | 1913 |
| 7 | ss | 1923 |
| 8 | 许 | 1913 |
| 9 | 应 | 1913 |
| 10 | Aron | 1913 |
+----+------+------+
5 rows in set
+----+------+------+
| 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
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
+----+------+------+
| id | name | ban |
+----+------+------+
| 1 | yiyq | 1913 |
| 7 | ss | 1923 |
| 8 | yiyq | 1913 |
| 9 | yiyq | 1913 |
| 10 | yiyq | 1913 |
+----+------+------+
5 rows in set
Delete the data: the FROM accout the SELECT *;
+ ---- + ------ + ------- +
| the above mentioned id | name | Money |
+ ---- + ------ + - + ------
|. 1 | A | 800 |
| 2 | B | 1200 |
+ ---- + ------ + ------- +
2 in rows SET
+ ---- + ------ + ------- +
| the above mentioned id | name | Money |
+ ---- + ------ + - + ------
|. 1 | A | 800 |
| 2 | B | 1200 |
+ ---- + ------ + ------- +
2 in rows SET
DELETE FROM accout WHERE name="a";
Query OK, 1 row affected
Query OK, 1 row affected
SELECT*FROM accout;
+----+------+-------+
| id | name | money |
+----+------+-------+
| 2 | b | 1200 |
+----+------+-------+
1 row in set
+----+------+-------+
| id | name | money |
+----+------+-------+
| 2 | b | 1200 |
+----+------+-------+
1 row in set
When you create a table to create the index:
INDEX id;
TRUNCATE also delete the data, but it is to delete a table in a reconstruction of the same table.
Create an index:
CREATE [UNIQUE / FULLTEXT / SPATIAL] INDEX ON table index name (field name [(length)] [ASC / DESC]);
The general index without anything,
UNIQUE: optional parameter represents a unique constraint,
FULLTEXT: optional parameter that indicates the full text of the constraints
SPATIAL: optional parameter represents the spatial constraints
ALTER created by:
ALTER TABLE table name ADD [UNIQUE / FULLTEXT / SPATIAL] INDEX index name (field [(length)] [ASC / DESC]);
Ordinary Index: ALTER TABLE book ADD INDEX inter_id (bookid);
Delete the index:
1.ALTER TABLE table DROP INDEX field name;
2.DROP INDEX index name ON table name;