SQL command Encyclopedia-Chinese and English Control 1th/3 page _mssql

Source: Internet
Author: User
Tags create index create domain
SQL command Encyclopedia-Chinese and English control
--Statement function
--Data manipulation
SELECT-Retrieve rows and columns of data from a database table
INSERT-Add new data rows to a database table
Delete-Deletes rows of data from a database table
Update--updating data in a database table
--Data definition
CREATE table--Creating a database table
DROP table--Deletes a table from the database
ALTER TABLE--modifying database table structure
Create View--Creates a view
Drop view-Removing views from the database
Create index--creates an index for a database table
Drop INDEX--deletes an index from the database
Create PROCEDURE--Creating a stored procedure
Drop PROCEDURE--removing stored procedures from the database
Create TRIGGER--creating a trigger
Drop TRIGGER--removing triggers from the database
CREATE schema--Adding a new schema to the database
Drop schema--Deletes a schema from the database
Create domain--creating a data domain
Alter domain--changing field definitions
Drop domain--deletes a field from the database
--Data control
Grant-Granting User access
Deny--Deny user access
REVOKE--Unlock user access rights
--Transaction control
COMMIT--End current transaction
ROLLBACK--Abort current transaction
SET TRANSACTION--Defining the current transaction data access characteristics
--Programmed SQL
DECLARE--Set cursors for queries
Explan--Describes a data access plan for a query
Open--Retrieving query results opens a cursor
FETCH--Retrieves a row of query results
Close--Closing cursors
PREPARE-Preparing SQL statements for dynamic execution
Execute-Execute SQL statements Dynamically
DESCRIBE--Describe a prepared query
---local variables
DECLARE @id char (10)
--set @id = ' 10010001 '
Select @id = ' 10010001 '
---global variables
---must begin with @@

--if ELSE
DECLARE @x int @y int @z int
Select @x = 1 @y = 2 @z=3
If @x > @y
print ' x > y '--printing string ' x > Y '
else if @y > @z
print ' Y > z '
else print ' Z > y '

--case
Use Pangu
Update employee
Set e_wage =
Case
When job_level = ' 1 ' then e_wage*1.08
When job_level = ' 2 ' then e_wage*1.07
When job_level = ' 3 ' then e_wage*1.06
else e_wage*1.05
End

--while CONTINUE Break
DECLARE @x int @y int @c int
Select @x = 1 @y=1
While @x < 3
Begin
Print @x--Prints the value of the variable x
While @y < 3
Begin
Select @c = 100*@x + @y
Print @c--printing the value of variable C
Select @y = @y + 1
End
Select @x = @x + 1
Select @y = 1
End

--waitfor
--An example waits 1 hours 2 minutes 3 seconds before executing the SELECT statement
WAITFOR DELAY ' 01:02:03 '
SELECT * FROM Employee
--for example, wait until 11 o'clock at 8 minutes before executing the SELECT statement
waitfor time ' 23:08:00 '
SELECT * FROM Employee
Current 1/3 page 123 Next read the full text

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.