SQL Server and Access database structure SQL statements

Source: Internet
Author: User
Tags table name access database
The following are common SQL statements used by SQL Server and Access to operate database structures.
The content is organized by Hai Wa. If the content is incorrect or incomplete, please submit it. Thank you.
Create a table:
Create table [table name]
(
[Automatic number field] int IDENTITY (1, 1) primary key,
[Field 1] nVarChar (50) default 'default value 'null,
[Field 2] ntext null,
[Field 3] datetime,
[Field 4] money null,
[Field 5] int default 0,
[Field 6] Decimal (12, 4) default 0,
[Field 7] image null,
)
Delete table:
Drop table [table name]
Insert data:
Insert into [table name] (Field 1, field 2) VALUES (100, '51windows. Net ')
Delete data:
Delete from [table name] WHERE [field name]> 100
Update data:
UPDATE [table name] SET [Field 1] = 200, [field 2] = '51windows. Net' WHERE [field 3] = 'haiwa'
New field:
Alter table [TABLE name] ADD [field name] NVARCHAR (50) NULL
Delete field:
Alter table [TABLE name] drop column [field name]
Modify field:
Alter table [TABLE name] alter column [field name] NVARCHAR (50) NULL
Rename a table: (Access to rename a table, refer to the article: rename a table in Access database)
Sp_rename 'table name', 'New table name', 'object'
New constraint:
Alter table [TABLE name] add constraint name CHECK ([CONSTRAINT field] <= '2017-1-1 ')
Delete constraints:
Alter table [TABLE name] drop constraint name
Create default value
Alter table [TABLE name] add constraint default name: '51windows. Net' FOR [field name]
Delete default value
Alter table [TABLE name] drop constraint default name
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.