Select * fromStudent--Querying the databaseCreate Databases20150417--New DatabaseDrop Database [20150325] --to delete a database number starts with [] surround Uses20150417--Working with DatabasesGo --connector is not written or can beCreate TableStudent--Create a table(Codeint not NULL,--columnNamevarchar( -) not NULL,--columnSexint,--columnDegreedecimal( -,2) not NULL--column) GoInsert intoStudentValues(1,'Zhang San',0, About);--Insert data corresponds to the above table four column insert value corresponding data typeInsert intoStudentValues(3,'John Doe',1, the);Insert intoStudent (Code,name,degree)Values(4,'Harry', the);--Specify columns to addGoUpdateStudentSetSex=0UpdateStudentSetSex=0 whereCode=3 --Modify a column's value to select a row in whereUpdateStudentSetName='Tianqi' whereCode=4 --wheres filtering modifies a control conditionGoSelect * fromStudentSelect * fromTongxunluwhereName=' Zhang San'--EnquiryGoUpdateStudentSetName='spacecraft', code=5, Degree= About whereName='Tianqi'Delete fromStudent--Delete all dataDelete fromStudentwhereCode=3 --Delete a row of code=3Drop TableStudent--Delete a table--primary key plays a unique role in improving query efficiencyCreate TableTeacher (TNOint Primary Key Identity(1,1),--self-growing primary keyTnamevarchar( -))--Enquiry--select *from table where column name and column name
Create TableXinxibiao (Noint Primary Key Identity(1,1),--self-increment primary key namevarchar( -) not NULL, Sexvarchar( -) not NULL, Ageint not NULL, Highint not NULL, TZdecimal( -,2) not NULL, Sfzhvarchar(Max) not NULL, Zhuzhivarchar(Max) not NULL)Insert intoXinxibiaoValues('Hong Yi','male', -, the, -,'370012598632152233','Hong Kong')Select * fromXinxibiaoSelect * fromXinxibiaowhereHigh>163 andSex='male'UpdateXinxibiaoSetName='Zhang Ye' whereName='OSPU'--between and between what and whatSelect * fromXinxibiaowhereHighbetween 165 and 175Select * fromXinxibiaowhereName like 'Li%'--the name of Li in the query table--% is a wildcard can replace any character and data like the meaning of
SQL Server Learning notes