Database -- add field statement

Source: Internet
Author: User
Generic Syntax: altertable [Table name] add [field name] field property default value is an optional parameter instance: altertable class Table 2addCOLUMN group int0 The following example may be true columnaltertable [Table name] add field name smallintdefault0 add numeric field, integer, default value 0 alte

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 column alter table [table name] add field name smallint default 0 add numeric field, integer, default value 0 alte

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.

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.