The INSERT INTO command is used to insert data into the table.
INSERT INTO command format: INSERT into < table name > [(< Field name 1>[,.. < field name n >])] VALUES (value 1) [, (value N)];
First show tables; There is a MyClass table. insert two records into table MyClass, these two records indicate that: 1 is named Tom with a score of 96.45, 2 for the named Joan, and 82.99 for the named Wang with the number 3.
[SQL]
Plain Text View
Copy Code
INSERT into MyClass values (null, ' Tom ', 1,96.45), (null, ' Joan ', 1,82.99), (null, ' Wang ', 2, 96.59);
The Select from command is used to query the data in the table.
Command format: Select < Field 1, Field 2, ...> from < table name > where < expression >;
For example, view all the data in the table MyClass:
[SQL]
Plain Text View
Copy Code
Slect * from MyClass;
Query results
<ignore_js_op>
query all data. png (30.95 KB, download number: 0)
Download attachments
2016-6-25 14:32 Upload
The delete from command is used to delete data from a table.
Delete from command format: Delete from table name where expression
For example, delete the record numbered 1 in table MyClass:
[SQL]
Plain Text View
Copy Code
Delete from MyClass where id=1;
The data in the following table is removed as follows:
[SQL]
Plain Text View
Copy Code
Mysql> Select * FROM myclass;+----+------+-----+--------+| ID | name | sex | Degree |+----+------+-----+--------+| 2 | Joan | 1 | 82.99 | | 3 | Wang | 2 | 96.59 |+----+------+-----+--------+2 rows in Set (0.00 sec)
The update set command is used to modify the data in the table.
Update SET command format: Update table name SET field = new value,... where condition;
Examples are as follows:
[Shell]
Plain Text View
Copy Code
Update MyClass set name= ' ck ' where id=2;
The updated data is as follows:
[SQL]
Plain Text View
Copy Code
Mysql> SELECT * FROM myclass;+----+------+-----+--------+| ID | name | sex | Degree |+----+------+-----+--------+| 2 | CK | 1 | 82.99 | | 3 | Wang | 2 | 96.59 |+----+------+-----+--------+2 rows in Set (0.00 sec)
http://www.sodu666.com/1/
http://tieba.sodu666.com/
MySQL common commands (4) Inserting, querying, deleting, modifying data