1 Basic Introduction to DML language 1.1 DML language
- DML language, data manipulation language.
Classification of 1.2 DML languages
- Inserting: Insert
- Updated: Update
- Remove: Delete
2 INSERT statement 2.1 syntax for INSERT statement
Insert into Values (value 1, value 2,......);
2.2 Prepare (Import data)
Use' Girls ';DROP TABLE IF EXISTS' admin ';CREATE TABLE' admin ' (' id ' )int( One) not NULLauto_increment, ' username 'varchar(Ten) not NULL, ' password 'varchar(Ten) not NULL, PRIMARY KEY(' id ')) ENGINE=InnoDB auto_increment=3 DEFAULTCHARSET=UTF8;Insert into' Admin ' (' id ', ' username ', ' password ')Values(1,'John','8888'),(2,'Lyt','6666');DROP TABLE IF EXISTS' Beauty ';CREATE TABLE' Beauty ' (' ID ')int( One) not NULLauto_increment, ' name 'varchar( -) not NULL, ' sex 'Char(1)DEFAULT 'female', ' borndate 'datetime DEFAULT '1987-01-01 00:00:00', ' phone 'varchar( One) not NULL, ' photo ' blob, ' boyfriend_id 'int( One)DEFAULT NULL, PRIMARY KEY(' id ')) ENGINE=InnoDB auto_increment= - DEFAULTCHARSET=UTF8;Insert into' Beauty ' (' id ', ' name ', ' sex ', ' borndate ', ' phone ', ' photo ', ' boyfriend_id ')Values(1,'spokesperson','female','1988-02-03 00:00:00','18209876577',NULL,8),(2,'Ms. Cang','female','1987-12-30 00:00:00','18219876577',NULL,9),(3,'Angelababy','female','1989-02-03 00:00:00','18209876567',NULL,3),(4,'Reba','female','1993-02-03 00:00:00','18209876579',NULL,2),(5,'Chou-dong Rain','female','1992-02-03 00:00:00','18209179577',NULL,9),(6,'Zhou Zhijo','female','1988-02-03 00:00:00','18209876577',NULL,1),(7,'Keilingshan','female','1987-12-30 00:00:00','18219876577',NULL,9),(8,'Small Zhao','female','1989-02-03 00:00:00','18209876567',NULL,1),(9,'Double son','female','1993-02-03 00:00:00','18209876579',NULL,9),(Ten,'Wang','female','1992-02-03 00:00:00','18209179577',NULL,4),( One,'Summer Snow','female','1993-02-03 00:00:00','18209876579',NULL,9),( A,'Zhao','female','1992-02-03 00:00:00','18209179577',NULL,1);DROP TABLE IF EXISTS' Boys ';CREATE TABLE' Boys ' (' ID ')int( One) not NULLauto_increment, ' Boyname 'varchar( -)DEFAULT NULL, ' USERCP 'int( One)DEFAULT NULL, PRIMARY KEY(' id ')) ENGINE=InnoDB auto_increment=5 DEFAULTCHARSET=UTF8;Insert into' Boys ' (' id ', ' boyname ', ' USERCP ')Values(1,'Zhang Mowgli', -),(2,'Luhan', -),(3,'Huang Xiaoming', -),(4,'Duan Yu', -);
2.3 Application of INSERT statement
- Example: Add a new piece of data to the goddess table
INSERT intoBeauty (ID, NAME, sex, borndate, phone, photo, boyfriend_id)VALUES ( -, 'Tang Yixin', 'female', '1990-04-23', '18988888888', NULL, 2 );
3 Modifying statement 3.1 syntax for modifying statements
Update set Column = value,......,[where filter condition ]
3.2 Application of Modified statements
- Example: Modifying the name of the goddess of Don in the beauty table is 13899999999
UPDATE Beauty SET = ' 13899999999 ' WHERE like '% don% '
4 Basic Introduction To DELETE statement 4.1 DELETE statement
Delete from [where filter condition ];
4.2 Application of DELETE statement
- Example: Deleting a name containing the goddess of Don
DELETE from BeautyWHERElike '% of don ';
MySQL Basic four