SQL Server and Access Operating Database Structure SQL Statements

xiaoxiao2021-03-06  40

Here is the common SQL for SQL Server and Access Operating Database Structure, I hope to help you.

The content is organized by Huaba. Please ask if it is incorrect and incomplete. Thank you.

New Table:

Create Table [Name]

(

[Automatic Number Field] Int IdnessTies (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 the table:

DROP TABLE [Name]

Insert data:

INSERT INTO [Table] (Field 1, Field 2) VALUES (100, '51windows.net')

delete data:

Delete from [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 [Name] Add [Field Name] NVARCHAR (50) NULL

Delete fields:

ALTER TABLE [Name] DROP Column [Field Name]

Modify the field:

Alter Table [Name] ALTER Column [Field Name] NVARCHAR (50) NULL

Rename table: (Access Rename, please refer to article: Rename table in Access database)

Sp_rename 'table name,' new table name, 'Object'

New constraints:

ALTER TABLE [Table Name] Add constraint constraints Check ([constraint field] <= '2000-1-1')

Delete constraint:

ALTER TABLE [Table Name] DROP Constraint Constraint Name

New default value

ALTER TABLE [Table Name] Add constraint default name default '51windows.net' for [field name]

Delete the default

ALTER TABLE [Table] DROP Constraint Default Name

转载请注明原文地址:https://www.9cbs.com/read-55393.html

New Post(0)