SQL Study Notes 1 Basic SQL knowledge

Source: Internet
Author: User
For more information, see. Although the text is short, the content is based on experience.

For more information, see. Although the text is short, the content is based on experience.

Common field types: bit (0 and 1), datetime, int, varchar, and nvarchar (which may contain nvarchar in Chinese)

Differences between Varchar, nvarchar, and char (n): Fill in spaces when char (n) is less than n.

In SQL statements, strings are enclosed in single quotes.

SQL statements are case insensitive. Not sensitive is the SQL keyword, and the string value is still sensitive.

Simple INSERT statement insert into Person (Id, Name, Age) VALUES (1, 'Jim ', 20)

Common int and uniqueidentifier as primary key data types

Identity specification: automatically fill in the value of the primary key. Set the field "Yes ID column" to "yes". A table can only have one ID column.

The Guid algorithm is an efficient algorithm that generates unique identifiers .. Method for generating Guid in. Net: Guid. NewGuid () returns the Guid type. The Guid generated in SQL server is newid ()

The data inserted with Guid is inconsistent with the displayed data.



Data Update

Update a column: Update person set Age = 30

Update multiple columns: updage person set Age = 30, Name = 'Tom'

Update part of data: update person set age = 30, where Name = 'Tom'

Note that the SQL statement uses single = instead of =



Delete all data in a table: delete from person (the drop statement deletes the table)

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.