-- 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
//