Get the App
SLTechnology News&Howtos  ›  Database  › 

A brief introduction to the manipulation language of mysql database

Shulou Source: shulou.com Published: 2022-06-01 19:21:31 10月03日 Update

The following is about the manipulation language of mysql database. The secret of the text is that it is close to the topic. So, no gossip, let's go straight to the following, I believe you will benefit from reading this article on the manipulation language of mysql database.

Addition, deletion, modification and search of Dml language

Addition, deletion, modification and search of dml language

Insert INSERT [INTO] table name [(column name)] VALUES (values list)

Example: INSERT INTO Students (SName,SAddress,SGrade,SEmail,SSEX)

VALUES ('Zhang Qingcai', 'Shanghai Songjiang', 6)

Note 1:

Insert one row of data at a time, not just half a row or several columns of data

The validity of the inserted data will be verified in accordance with the requirements of the integrity of the entire row.

Note 2:

The data type, precision, and number of decimal places for each data value must match the corresponding column

Note 3:

Cannot specify a value for the identity column

Note 4:

If you specify that a column is not allowed to be empty when designing the table, you must insert data

Note 5:

The inserted data item is required to meet the requirements of the check constraint

Note 6:

Columns with default values, you can use the DEFAULT (default) keyword instead of the inserted numeric value

Example:

INSERT INTO Student (StudentNo,LoginPwd,StudentName,Sex,GradeId,Phone,Address,BornDate)

VALUES ('S1200902005' demagogy 'Zhang Feng', 'male', 1 '13212345678' defaults, '1987-6-2')

Insert multiple rows of data

The first method

Add data from an existing table to an existing table through the INSERT SELECT statement

INSERT INTO (column name)

SELECT

FROM

Example: INSERT INTO AddressList (name, address, email)

SELECT SName,SAddress,SEmail

FROM Students

The second method

Add data from an existing table to a new table through a SELECT INTO statement

SELECT (column name)

INTO

FROM

SELECT Students.SName,Students.SAddress,Students.SEmail

INTO AddressList

FROM Students

For the above mysql database manipulation language-related content, is there anything you don't understand? Or if you want to know more about it, you can continue to follow our industry information section.

Tags: Data matters precautions language database instance method statement valid one line following text subject number of digits keywords keywords content address place secret name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Docker Apple MariaDB Shulou Tech Info