SQL 3 for interview preparation-Data Management

Source: Internet
Author: User

1. T-SQL condition expression:

(1). Constant: contains one or more letters, numbers, or symbols (! @ #) Composition

(2). unary operator: Only one operand operator + represents an integer-represents a negative number ~ Complement Operator

(3) binary operator: the operator that combines two operands contains the arithmetic operator value assignment operator (=) bit operator comparison operator logical operator String concatenation operator (+) or unary operator

==><=<> (Not equal )! (Not)

 

(4). '_': a character like 'C _ 'must contain at least two characters

%: Any length string a like 'C %'

[]: A like '[1-9]' for data within the specified range

[^]: Data not in the specified range

(5). logical operators: And or not

The in keyword is used to limit multiple returned values.

 

2. T-SQL insert data

Insert into Table Name (column, column, column ...) Values (Value column ,,,)

 

Add existing table dataNew existing tableMedium: inster into newtable new table (column) Select column from old table (this can be noted: like English: insert query data from old table to new table)

Add existing table dataThe new table does not exist.Medium: Select column into new table from old table

The preceding statement cannot be specified. Therefore, we need to create a new ID column. The syntax is as follows:

Select other columns, identity (data type, identification seed, identification growth) as column name

Into new table

Form old table

 

Merge data using the Union keyword for insertion

 

Insert table name (column name)

Select column value Union

Select column value Union

Select column value Union

Select column Value

Union is not required for the last row.

 

3. Update data with T-SQL

Update table name set column name = new value where Condition

 

4. Use T-SQL to delete data

Delete from table name where Condition

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.