1. Add data
INSERT INTO table name(field name 1, field name 2...) values(value 1, value 2...);INSERT INTO newstu(id,name)values(12,'Hu Ge');
INSERT INTO table name values(value 1, value 2);
INSERT INTO newstu values(12,'Hu Ge');
Note: Values
and fields must be in one-to-one correspondence, with the same number and type;
Within the length range;
· Except for numeric types, other field type values must be enclosed in quotation marks (single quotation marks are recommended);
· If you want to insert a null value, you can leave the field blank, or insert NULL;
2. Modify table data
UPDATE table name SET field name=value, field name=value...;UPDATE newstu SET id=5, STU_NAME='Hu Ge'; #When modifying this, make sure that the modified field is not the primary key
UPDATE table name SET field name= Value, field name=value... WHERE condition;
UPDATE newstu SET id=10, STU_NAME='HUGE' WHERE id=10; #Modify eligible fields
3. Delete data
DELETE FROM table name; #delete all data in the table DELETE FROM NEWSTU; #delete all data in the table DELETE FROM NEWSTU WHERE ID=10; DELETE FROM NEWSTU WHERE ID>10 && ID<=20; #delete the table that meets the conditions Note : · Use DELETE and TRUNCATE to delete all the data in the table because the way they delete is different · DELETE is to delete the data in the table one by one. ·TRUNCATE is to delete the table and then rebuild the table. (It is recommended to use this statement to empty the table)4. Query data
SELETE * FROM table name; #Query all data in thetable SELETE ID FROM table name; #Query all data in the specified field in the table
SELETE * FROM NEWSTU WHERE condition; #Query all data in the table that meet the conditions
SELETE ID FROM NEWSTU WHERE condition ;