MySQL add, delete and modify data

1. Add data

insert  into staff values ​​( 1 , ' Li Bai ' , ' Male ' , ' 701-2-28 ' , ' [email protected] ' , 61 );
 /* Insert all fields. Be sure to insert them in order--strings and dates need to be single quotes, numbers are not required, and each field is separated by commas */ 
/*Be careful not to have less or more field values*/
insert into staff (id,username,gender, age) values ​​( 5 , ' Meng Haoran ' , ' Male ' , 51 ) /* Insert data by field name, separated by commas */

2. Modify the data

update staff set gender =  ' female '  where id =  5 ; /* Conditional modification - modify the table name as staff, gender becomes 'female', and the field is the field with id = 5 */
update staff set gender = ' female ' ,age = 61  where id = ' 1 ' ; /* Modify multiple fields at the same time, separated by commas */

3. Delete data

delete  from staff where id =  5 ;     /* Delete with condition -- delete all fields with id 5 */

 4. Query data ---- key point

select  *  from staff;      /* Query the data of all columns of the table named staff */
select id, username from stall;   /* Query the specified column */

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325235690&siteId=291194637