MySQL Database manipulation language

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.