ASP common SQL statements for manipulating database structures

Source: Internet
Author: User
sql| Data | database | database STRUCTURE | statement

New table:
CREATE table [table name]
(
AutoNumber field int IDENTITY (1,1) PRIMARY KEY,
[Field 1] nVarChar default ' defaults ' 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,
)

To delete a table:
Drop table [table name]

Insert data:
INSERT into [table name] (field 1, Field 2) VALUES (' webjx.com ')

Delete data:
DELETE from [table name] WHERE [field name]>100

Update data:
UPDATE [table name] SET [Field 1] = 200,[Field 2] = ' webjx.com ' WHERE [field three] = ' WEBJX '

New fields:
ALTER table [table name] ADD [field name] NVARCHAR (m) NULL

To delete a field:
ALTER table [table name] DROP COLUMN [field name]

To modify a field:
ALTER TABLE [table name] ALTER COLUMN [field name] NVARCHAR (m) NULL

Renaming tables: (Access renames tables, refer to article: renaming tables in an Access database)
sp_rename ' table name ', ' New table name ', ' OBJECT '

New constraint:
ALTER table [table name] ADD CONSTRAINT constraint name CHECK ([constraint field] <= ' 2000-1-1 ')

Delete constraint:
ALTER table [table name] DROP CONSTRAINT constraint name

Create a new default value
ALTER table [table name] ADD CONSTRAINT Default value name defaults ' webjx.com ' for [field name]

Delete default values
ALTER table [table name] DROP CONSTRAINT Default value name



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.