如何用编程方法,在access数据库内增加表?可以给我一个具体点的例子吗?

解决方案 »

  1.   

    //Qry: TADOQuery;
    Qry.Close;
    Qry.SQL.Text := 'create talbe ......';
    Qry.ExecSql;
      

  2.   

    create table
    select * into tableName from ...
      

  3.   

    可以用sql语句来创建,只不过access只支持每次一句sql语句!
      

  4.   

    用ADOConnection
    ADOConnection.Execute('Create Table 表名(字段名 字段类型')字段类型 char,int,date等
    Create table tab(f1 int,f2 char(20))
      

  5.   

    给一个数据源adoquery1连上那个数据库,然后:
    在一个button上写下如下代码:
    begin
      with adoquery1 do
        begin
          sql.clear;
          sql.add('create table 表名(字段名 字段类型)');
          execsql;
        end;
    end;
     ok, 一个新表诞生了
      

  6.   

    var 
      newtable:ttable;
      newindexoptions:tindexoptions;
    begin
      ……
      newindexoptions:=[ixprimary,ixunique];
      ……
      newtable.indexdefs.add('primaryindex,"添加的 index",newindexoptions);
      ……
      createtable;
    end;
    这样就能建立主键,并且是唯一的。