Maison >base de données >tutoriel mysql >SQL Access创建表
一、创建一张空表: Sql="Create TABLE [表名]" 二、创建一张有字段的表: Sql="Create TABLE [表名] ([字段名1] MEMO NOT NULL, [字段名2] MEMO, [字段名3] COUNTER NOT NULL, [字段名4] DATETIME, [字段名5] TEXT(200), [字段名6] TEXT(200)) 字段类型: 2
一、创建一张空表:
Sql="Create TABLE [表名]"
二、创建一张有字段的表:
Sql="Create TABLE [表名]
([字段名1] MEMO NOT NULL,
[字段名2] MEMO,
[字段名3] COUNTER NOT NULL,
[字段名4] DATETIME,
[字段名5] TEXT(200),
[字段名6] TEXT(200))
字段类型:
2 : "SmallInt", // 整型
3 : "Int", // 长整型
4 : "Real", // 单精度型
5 : "Float", // 双精度型
6 : "Money", // 货币
7 : "DateTime", // 日期时间
11 : "Bit", // 是否
13 : "TimeStamp",
17 : "TinyInt", // 字节
72 : "UniqueIdentifier", // 同步复制 ID
128 : "Binary",
129 : "Char",
130 : "NChar",
131 : "Decimal", // 小数
133 : "DateTime",
135 : "SmallDateTime",
200 : "VarChar",
201 : "Text",
202 : "VarChar", // 文本
203 : "Text", // 备注
204 : "Binary", // 二进制
205 : "Image" // OLE 对象以下字段为无编码字段(NChar、NVarchar、NText型)
8,128,130,202,203,204,205 以下字段为按当前系统内码编码的字段(Asp中可用CodePage=936纠正为gb2312内码) 129,200,201
三、
在现有的表中增加字段:
Sql="alter table [表名] add column [字段名] varchar(200)"
修改字段类型:
Sql="alter table [表名] Alter COLUMN 字段名] varchar(50)"
删除表:
Sql="Drop table [表名]"
删除字段:
sql="alter table [表名] drop [字段名]"
修改字段:
Alter TABLE [表名] Alter COLUMN [字段名] 类型(大小) NULL
新建约束:Alter TABLE [表名] ADD CONSTRAINT 约束名 CHECK ([约束字段]
删除约束:Alter TABLE [表名] Drop CONSTRAINT 约束名
新建默认值:Alter TABLE [表名] ADD CONSTRAINT 默认值名 DEFAULT 'Gziu.CoM' FOR [字段名]
删除默认值:Alter TABLE [表名] Drop CONSTRAINT 默认值名 ======================================= conn.open connstr sql="alter table [tablename] add hehe char(20)" conn.execute(sql) response.write("添加成功")
字段类型对应数值 ''
---- 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 adBinary = 128
Const adVarBinary = 204
Const adLongVarBinary = 205
Const adChapter = 136
Const adFileTime = 64
Const adPropVariant = 138
Const adVarNumeric = 139