Dml Language
Change and delete
DML language additions and deletions change
Insert INSERT [into] table name [( column name )] VALUES ( value list )
Example: INSERT into Students (sname,saddress,sgrade,semail,ssex)
VALUES (' Zhang Qing ' , ' Shanghai Songjiang ', 6, ' [email protected] ', 0)
Note 1:
Each time you insert a row of data, you cannot insert only half a row or columns of data
Whether the inserted data is valid will be examined in accordance with the integrity of the entire line
Note 2:
The data type, precision, and scale of each data value must match the corresponding column
Note 3:
Cannot specify a value for an identity column
Note 4:
If you specify that a column is not allowed to be empty when you design the table, you must insert the data
Note 5:
Inserted data items that require compliance with the requirements of the check constraint
Note 6:
columns with default values, you can use the Default(default) keyword instead of inserted value
Instance:
INSERT into Student (studentno,loginpwd,studentname,sex,gradeid,phone,address,borndate)
VALUES (' S1200902005 ', default, ' Zhang Feng ', ' male ', 1, ' 13212345678 ', default, ' 1987-6-2 ')
Inserting multiple rows of data
The first of these methods
through INSERT SELECT statement to add data from an existing table to a table that already exists
INSERT into < table name > ( column name )
SELECT < column name >
From < source table name >
Example: INSERT into addresslist ( name , address , email )
SELECT Sname,saddress,semail
from Students
The second method of
through SELECT into statement to add data from an existing table to a new table
SELECT ( column name )
into < table name >
From < source table name >
SELECT Students.sname,students.saddress,students.semail
into AddressList
From Students
This article is from "Happy Learning" blog, please be sure to keep this source http://983865387.blog.51cto.com/9838888/1917417
MySQL Database manipulation language