如何產生Access檔的主索引 |
尚未結案
|
franky0312
一般會員 發表:1 回覆:1 積分:0 註冊:2003-10-20 發送簡訊給我 |
tech_state板大您好,小弟參考您的
http://delphi.ktop.com.tw/topic.php?TOPIC_ID=32427
中的寫法,而小弟又想在column1中加入主索引...寫法如下.. // Add Fields
ADOQuery2->Close();
ADOQuery2->SQL->Text = "alter table tb1 add column column1 char(10) ";
ADOQuery2->ExecSQL();
ADOQuery2->SQL->Text = "alter table tb1 add index column1 (column1)";
ADOQuery2->ExecSQL();
ShowMessage("Add Fields OK");
delete ADOQuery2; 但不知為什麼都會有錯誤的訊息,可以請教您如何解決嗎? ps.小弟是參考http://www.kuix.de/links/sql.html中的寫法..不過小弟沒學過sql,所以不太懂... ALTER TABLE tbl_name alter_spec [, alter_spec ...] alter_specification:
ADD [COLUMN] create_definition [FIRST | AFTER column_name ]
or ADD [COLUMN] (create_definition, create_definition,...)
or ADD INDEX [index_name] (index_col_name,...)
or ADD PRIMARY KEY (index_col_name,...)
or ADD UNIQUE [index_name] (index_col_name,...)
or ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}
or CHANGE [COLUMN] old_col_name create_definition
or MODIFY [COLUMN] create_definition
or DROP [COLUMN] col_name
or DROP PRIMARY KEY
or DROP INDEX index_name
or RENAME [AS] new_tbl_name
or table_options
|
franky0312
一般會員 發表:1 回覆:1 積分:0 註冊:2003-10-20 發送簡訊給我 |
找了好久...
終於找到答案嚕... // Add Fields
ADOQuery2->Close();
ADOQuery2->SQL->Text = "alter table tb1 add column column1 char(10) ";
ADOQuery2->ExecSQL();
ADOQuery2->SQL->Text = "alter table tb1 PRIMARY KEY (column1)";
ADOQuery2->ExecSQL();
ShowMessage("Add Fields OK");
delete ADOQuery2;
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |