SQL Server Basic Operations

Source: Internet
Author: User

Relational: Use a relationship to represent the connection between entity information and entities

Relationship: is a two-dimensional table with rows and columns of tables

Creating database: Create library name; fault level creation: CREATE database if not exists library name;

When creating a database with a system reserved word, wrap the method with the library name (enclose the system reserved word in inverted quotation marks)

Specifies the character set default CharSet =GBK;

Delete database drop DB if exists library name;

Creating table: Create Table name (field, attribute, keyword primary key);

Modify the structure of the table: ALTER TABLE name add field property;

Modify properties: ALTER TABLE name modify field property;

Add data to a table: INSERT into Table name (property) values (value), attribute to value one by one

If the table structure of the other table or the corresponding field type is exactly the same, then you can write the INSERT into table name Select*from other tables

If the other table fields are not consistent, you can insert some of the field contents, but the request type corresponds

Insert into Student2 (student_id,student_name) select Student_id,studentname from Student_info;

Query data select* or field list from table name where condition

Select + as number, GETDATE () as Date, NEWID () as number;

Querying and Grouping

Select F_money,count (*), GETDATE () as Shijian from Temployee Group by F_money have COUNT (*) >1; select F_money,count (*) From Temployee where f_age>22 Group by F_money;//group by in the back of the where, in front of the having statement, having is filtering the information after grouping, the columns that can be used are the same as in select

Conditional query

Select Top 3*from temployee ORDER by F_money ASC;

  

Modify data:Update table name set field name = new Value, ... Where Condition ...

Delete Data : Delete from table name where. ORDER BY ... Limit

SQL Server Basic Operations

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.