Data Operations in data manipulation language

Source: Internet
Author: User

-- Table data operations

-- Input data

Select * from student

-- Note: into used between insert and table names is an optional keyword.

Insert into student (student ID, name, gender, age, Major)

Values ('003 ', 'yanglil', 'female', 18, 'Family Planning ')

Insert into student (student ID, name, gender, age, Major)

Values ('004 ', 'yanglil', 'female', 18, 'Family Planning ')

Delete student where student ID = '004'

Alter table student

Add constraint ck check (Gender in ('male', 'female '))

Insert into student

(Student ID, name, gender, age, Major)

Values ('005 ', 'zhang san', 'mal', 18, 'network Project ')

-- Modify Table Data

-- In data manipulation language, modifying data means updating data with the update keyword.

/*

Syntax:

Update table name

Set column name = new data

Where condition expression

*/

Use test

Go

Alter table student

Add remarks char (20)

Update student

Set gender = 'graduated'

-- Based on conditions and new data

Update student

Set remarks = 'Students on reading'

Where name = 'wang fang'

-- Delete data

-- Delete a row of records each time

/*

Syntax structure

Deleted table name

Where condition expression

*/

Delete student

Where student ID = '005'

-- Delete all records of a table at one time: Clear the table

-- There are two methods

-- Method 2 is faster

-- Method 1;

Delete Course Selection

-- Method 2:

Truncate table Course Selection

//

-- Delete a table

Drop table hh

//

Related Article

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.