SQL Server Database Knowledge Essentials, organize yourself

Source: Internet
Author: User
Tags mathematical functions

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.