access|server| Data | database | database STRUCTURE | statement
The following are common SQL Server and Access operations database structures that you want to help.
The content is sorted by Eva, the incorrect and incomplete place also please put forward, thank you.
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 (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 three] = ' Haiwa '
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 ' 51WINDOWS '. NET ' for [field name]
Delete default values
ALTER table [table name] DROP CONSTRAINT Default value name