Office中国论坛/Access中国论坛

标题: 在“CREATE TABLE”中如何创建索引 [打印本页]

作者: wang1999    时间: 2014-3-21 12:25
标题: 在“CREATE TABLE”中如何创建索引
今天利用JET SQL的“CREATE TABLE”来创建表的过程中遇到一点问题
就是无法实现创建普通索引
        strSQL = "CREATE TABLE Customers2 (CustId INTEGER, CLstNm TEXT (50), CONSTRAINT CustId NULL (CustId))"
       
我的目的就是一句SQL“CREATE TABLE”实现下面的功能
        strSQL = "CREATE TABLE Customers2 (CustId INTEGER, CLstNm TEXT (50))"
        strSQL = "CREATE INDEX CustId ON Customers2 (CustId)"




以下主键和唯一键可以通过“CREATE TABLE”创建
    Dim cnn As ADODB.Connection
    Dim strSQL As String
    Set cnn = CurrentProject.Connection
    strSQL = "CREATE TABLE Customers2 (CustId INTEGER, CLstNm TEXT (50), CONSTRAINT CustId UNIQUE (CustId))"
    strSQL = "CREATE TABLE Customers2 (CustId INTEGER, CLstNm TEXT (50), CONSTRAINT CustId PRIMARY KEY (CustId))"
    cnn.Execute strSQL, , adExecuteNoRecords
    cnn.Close
    Set cnn = Nothing




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3