Tag:des ar sp Data on bs ef as sql
One. Add New data!
Insert single-line record
1.create table box (
name varchar () NOT NULL,
ID int. NOT NULL PRIMARY key,
student varchar, gender char (2) default 0 comment ' 0 male: 1 female '
);
INSERT into box (name, ID, Student) VALUES (' Xiaohong ', 123, ' 123 '), (' Bingxin ', 565, ' 334 ');
Select*from Box;
Insert new data: INSERT into table name (column name) values (list parameters) can also be added, (list parameters);
Insert multiple rows of data: INSERT into < table name > select <select statement;
Insert into games select year+12,city from games;
Insert Inti Students (Studenyname,studenyid) Select Studenyname+2,studenyid from Students.
Two. Update the new data.
1.update Table Name set the value to be changed where < filter conditions;
CREATE table Box3 (
name varchar () NOT NULL,
ID int. NOT NULL Primar Y key,
student varchar,
Gender char (2) default 0 comment ' 0 male: 1 female '
);
Insert into BOX3 (name, ID, Student) VALUES (' minxing ', 365, ' 668 '), (' Lunxun ', 778, ' 388 ');
Update set Box3 name= ' Xiaotao ', id= ' 596 ' where student= ' 668 ';
Delete from Box3 where id= ' 365 ' and student= ' 388 ';
Select*from Box3;
2. Delete data
Delete from table name where < filter conditions >
Delete from Box3 where id= ' 596 ';
Delete from Box3 where id= ' 335 ' and/or name= ' Xiaotao ';
One. Basic structure of the query:
Select column
From table name
where (filtered)
Group by ..... To group
Having a verdict ... Conditions
Order BY (sort) ASC Ascending, desc descending
Two:
Lookup: Select column name from table name
Select Name,student,subject from box;
Alias: Select name ' name ', subject ' award ' from box;
To return a qualified number of rows query:
Select Top 5 student from box (query first to fifth)
Three fuzzy query:
Select *from box where limit 0,4 (O is from 0 lines, 4 refers to length)
Select*from box where like '%liu% ';
Select age from Student order by age DESC limit 0, 8;
Data processing in SQL: