Aceess中直接用SQL语句创建一个表?(50分)

  • 主题发起人 yukaikai
  • 开始时间
Y

yukaikai

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样在Aceess中直接用SQL语句创建一个表?
 
create table tabname
(id autoincrement,
name char(20) not null,
age integer
)
 
前些时间总结,不全,但差不多可以用了
用SQL语句创建Access表

----------------------------------------------------------------------------
类型名称 TYPE 备注
----------------------------------------------------------------------------
自动编号 integer + identity(1,1)
文本 varchar(50) 括号中的数字为文本长度
长整型 integer
整型 short
双精度型 double,float
单精度型 real
字节型 byte
小数 NUMERIC(6,2)
货币 money
备注 text
日期/时间 date,time,datetime
是/否 bit
OLE 对象 OLEObject

----------------------------------------------------------------------------

主键 primary key
必填 not null
默认值 default 当为日期型时为 default date()
-----------------------------------------------------------------------------

示例
表名 字段名 类型 附属属性 说明
------- --------- ------------ --------------------------------- -------------------
create table mytable (m_id integer identity(1,1) primary key ,--自增型,主键
m_class varchar(50) not null default 'AAA' ,--文本,非空,默认值'AAA'
m_int integer not null ,--长整型,非空
m_numeric NUMERIC(6,2) ,--小数型
m_money money not null default 0.00 ,--货币型,非空,默认值0.00
m_memo text ,--备注型
m_date date default date() ,--日期型,默认为当前日期
m_boolean bit default yes ,--布尔型,默认为yes
m_blob OLEObject ,--BLOB型
m_double double ,--双精度型
m_float real) --单精度型
----------------------------------------------------------------------------------------------------------------------------

创建索引

示例1
create index myindex on mytable (m_class [DESC, ASC], m_int)
示例2
create unique index myindex on mytable (m_class) --创建无重复索引
注意:主键字段会被自动建立为没有重复的索引
 
谢谢回答,但是在Access中那个地方输入这些SQL语句呢?

不好意思,我比较笨!
 
没地方可以输入的。

你可以通过ODBC用其他方式控制,可以使用SQL。

 
可以使用SQL Explorer呀
通过ODBC或者SQLLINK都可以
 
在新建查询里进入页面后点sql图标
就可以了
 
谢谢回答!
 
用BDE连接好象也可以,然后用SQL EXPLORER或其它SQL工具输入SQL语句操作。
 
多人接受答案了。
 
顶部