database key points of knowledge:Primary KeyPRIMARY KeyReferencesFOREIGN KeydistinctGo heavyIdentitySelf-growthCheckConstraint Fenshudecimal( -,2)Check(Fenshu>=0 andFenshu<= -)--The input scores range from 0 to 100 UniqueUnique constraint Fenshuint Unique not NULL --The columns in the constraint are not allowed to have two identical non-null values, the specified column can have a null property, and a table can have more than one unique constraint Create proccreate a stored procedureAlter procModifying stored ProceduresDrop procTo Delete a stored procedureexecExecuting stored proceduresPrintOutputCreate ViewCreate a ViewDrop ViewDelete a viewCreate Triggercreate a stored procedureUpdate SetModify a row of data in a tableInsert into Valuesinserting data into a tableDelete fromDelete a row, or delete data from a tableCreate DatabaseCreate a database, delete a databaseDrop DatabaseDeleting a databaseJoin onHorizontal connection of the tableUnionVertical connection of tableDateDiffGives the difference between a date and a time functionSelect DATEDIFF( Year, Sbirthdy,GETDATE()) asAge, Sbirthdy fromStudentgetdateget current system timeGroup byGroupingGroup by havingfurther screening on a group basisAlter TableModify TableAlter TableBiao andSexvarchar( -) to add a column to the tableAlter TableBiaoDrop columnSex Delete a column All,inch, anyRangeDateAddreturns a new datetime value based on the specified date plus a period of timeSelectSbirthdy=DATEADD( Year,1, Sbirthdy) fromStudentDatePartreturns an int valueSelect DATEPART( Year, Sbirthdy) fromStudentDatenamereturn StringSelect Datename(MONTH, Sbirthdy) fromStudent Mathematical Functions:round Ceiling Floor Pi ABS Rand Ceiling--returns the smallest integer greater than or equal to the given number expressionFormat:Ceiling(123.45)Select CEILING(123.45) PowerReturns the value to the specified expression by the specified second partyPrint Power(2,2) Randreturns a random float value between 0 and 1Declare @a as float Set @a=RAND() Print @a Expreturns the specified value of the given float expressionPrint Exp(3) string function:substring LTrim Len Lower Upper Lenreturns the number of characters (not bytes) for a given string expression, excluding trailing space format:Len()Select LEN('Oh, hello.') Lefttake string function left Rightright-fetch string functionSelect Left('ABCDE',5) LowerConvert to lowercaseUpperConvert to uppercaseSelect LOWER('ABCDE') type conversion function:cast(data as type)Convert(type data)Select CONVERT(int,235) Select CAST(235 as int)
SQL Server Database Knowledge Essentials, organize yourself