--Create a database
Create DATABASE hq20161114
Go
--Using the database
Use hq20161114
Go
--Create student tables
CREATE TABLE Xuesheng
(
code int,
Name varchar (10),
Sex char (10),
Chengji Decimal (18,2)
)
--Add student information
INSERT into Xuesheng values (1001, ' One ', ' male ', 11)
INSERT into Xuesheng values (1002, ' two ', ' Male ', 22)
INSERT into Xuesheng values (1003, ' three ', ' female ', 33)
INSERT into Xuesheng values (1004, ' four ', ' female ', 44)
Go
--Querying data
SELECT * FROM Xuesheng
--Query data Specify single column
Select name from Xuesheng
--Querying data specifying multiple columns
Select Name,chengji from Xuesheng
--based on the conditions of the query score of more than 20
SELECT * FROM Xuesheng where chengji>=20
--Query the results of female students according to the conditions
Select Chengji from Xuesheng where sex= ' woman '
--Change the gender of Student No. 3rd to Male
Update Xuesheng set sex= ' man ' where code=1003
--Delete all
Delete from Xuesheng
--Add No. 5th study
INSERT into Xuesheng values (1005, ' five ', ' female ', 55)
--delete the specified line
Delete from Xuesheng where name= ' five '
November 14, 2016--sql CREATE DATABASE, table-check, insert, delete, change