Database -- add field statement, -- field statement
This article is based on the software of calligraphy and painting novels. The published content has nothing to do with this software.More comfortable reading, more comfortable writing, and easier Publishing
Generic Syntax: alter table [table name] add [field name] field property default value is an optional parameter
Instance:
Alter table class table 2 add COLUMN Group int 0
The following example may be true for column
Alter table [table name] add field name smallint default 0 add numeric field, integer, default value 0
Alter table [table name] add field name int default 0 add numeric field, long integer, default value 0
Alter table [table name] add field name single default 0 add numeric field, single precision type, default value is 0
Alter table [table name] add field name double default 0 add numeric field, double precision type, default value is 0
Alter table [table name] add field name Tinyint default 0 add numeric field, byte type, default value is 0
Alter table [table name] add field name text [null] add remarks field, [null] optional parameter
Alter table [table name] add field name memo [null] add remarks field, [null] optional parameter
Alter table [table name] add field name varchar (N) [null] Increase the variable-length text field size to N (1 ~ 255)
Alter table [table name] add field name char [null] increase fixed length text type field size to 255
Alter table [table name] add field name Datetime default function adds a date field, where the function can be now (), date (), etc., indicating the default value
(The above are the most common and there are other attributes. You can refer to the following data type description)
Delete field: alter table [table name] drop field name
Modify the size of a variable-length text field: alter table [table name] alter field name varchar (N)
Delete table: drop table [table name]
Create a table:
SQL = "CREATE TABLE [TABLE name] ([Field 1, and set it as the PRIMARY KEY] int IDENTITY (1, 1) NOT NULL CONSTRAINT PrimaryKey PRIMARY KEY ,"&
"[Field 2] varchar (50 ),"&
"[Field 3] single default 0 ,"&
"[Field 4] varchar (100) null ,"&
"[Field 5] smallint default 0 ,"&
"[Field 6] int default 0 ,"&
"[Field 7] date default date (),"&
"[Field 8] int default 1 )"
Conn.exe cute SQL
Null indicates that the field can be zero-length.
The software of calligraphy and painting novels is more comfortable to read, more comfortable to write, and easier to publish.