Create a table using SQLAccess

Source: Internet
Author: User
1. Create an empty table: SqlCreateTABLE [Table name] 2. Create a table with fields: SqlCreateTABLE [Table name] ([field name 1] MEMONOTNULL, [field name 2] MEMO, [field name 3] COUNTERNOTNULL, [field name 4] DATETIME, [field name 5] TEXT (200), [field name 6] TEXT (200) Field Type: 2

1. Create an empty TABLE: SQL = "Create TABLE [TABLE name]" 2. Create a TABLE with fields: SQL = "Create TABLE [TABLE name] ([field name 1] MEMO NOT NULL, [field name 2] MEMO, [field name 3] COUNTER NOT NULL, [field name 4] DATETIME, [field name 5] TEXT (200), [field name 6] TEXT (200) Field Type: 2

1. Create an empty table:

SQL = "Create TABLE [TABLE name]"

2. Create a table with fields:

SQL = "Create TABLE [TABLE name]

([Field name 1] memo not null,

[Field name 2] MEMO,

[Field name 3] counter not null,

[Field name 4] DATETIME,

[Field name: 5] TEXT (200 ),

[Field name 6] TEXT (200 ))

Field Type:

2: "SmallInt", // integer

3: "Int", // long integer

4: "Real", // single precision type

5: "Float", // Double Precision type

6: "Money", // currency

7: "DateTime", // Date and Time

11: "Bit", // whether

13: "TimeStamp ",

17: "TinyInt", // byte

72: "UniqueIdentifier", // synchronous replication ID

128: "Binary ",

129: "Char ",

130: "NChar ",

131: "Decimal", // Decimal

133: "DateTime ",

135: "SmallDateTime ",

200: "VarChar ",

201: "Text ",

202: "VarChar", // text

203: "Text", // remarks

204: "Binary", // Binary

205: "Image" // the following fields of the OLE object are unencoded fields (NChar, NVarchar, NText type)

8,128,130,202,203,204,205 the following fields are encoded by the current system internal code (CodePage = 936 in Asp can be corrected to gb2312 internal code) 129,200,201

III,

Add fields to the existing table:

SQL = "alter table [table name] add column [field name] varchar (200 )"

Modify Field Type:

SQL = "alter table [table name] Alter COLUMN field name] varchar (50 )"

Delete table:

SQL = "Drop table [table name]"

Delete field:

SQL = "alter table [table name] drop [field name]"

Modify Field:

Alter TABLE [TABLE name] Alter COLUMN [field name] type (size) NULL

Create CONSTRAINT: Alter TABLE [TABLE name] add constraint name CHECK ([CONSTRAINT field] <= '2017-1-1 ')

Delete CONSTRAINT: Alter TABLE [TABLE name] Drop CONSTRAINT name

New DEFAULT value: Alter TABLE [TABLE name] add constraint default Value Name DEFAULT 'gziu. com' FOR [field name]

Delete default value: alter TABLE [TABLE name] Drop CONSTRAINT default name ============================ ========= conn. open connstr SQL = "alter table [tablename] add hehe char (20)" conn.exe cute (SQL) response. write ("added successfully ")

Field type corresponds to the value''

---- DataTypeEnum Values ----

Const adEmpty = 0

Const adTinyInt = 16

Const adSmallInt = 2

Const adInteger = 3

Const adBigInt = 20

Const adUnsignedTinyInt = 17

Const adUnsignedSmallInt = 18

Const adUnsignedInt = 19

Const adUnsignedBigInt = 21

Const adSingle = 4

Const adDouble = 5

Const adCurrency = 6

Const adDecimal = 14

Const adnumeric= 131

Const adBoolean = 11

Const adError = 10

Const adUserDefined = 132

Const adVariant = 12

Const adIDispatch = 9

Const adIUnknown = 13

Const adGUID = 72

Const adDate = 7

Const adDBDate = 133

Const adDBTime = 134

Const adDBTimeStamp = 135

Const adBSTR = 8

Const adChar = 129

Const adVarChar = 200

Const adLongVarChar = 201

Const adwchar= 130

Const advarwchar= 202

Const adlongvarwchar= 203

Const ad binary = 128

Const adVarBinary = 204

Const adLongVarBinary = 205

Const adChapter = 136

Const adFileTime = 64

Const adpropvariant= 138

Constadvarnumeric = 139

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.