Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us
Restructuring Tables
Previous  Top  Next



Use Absolute Database DBManager utility (...\AbsoluteDatabase\Ultils\Bin\DBManager.exe), if you would like to change table structure manually.

To alter table from your application using TABSTable component, you could perform the following steps:

1.Open existing table to fill in RestructureFieldDefs and RestructureIndexDefs properties.  
2.Close table.  
3.Modify RestructureFieldDefs and RestructureIndexDefs properties (add, delete or change fields and indexes descriptions)  
4.Call RestructureTable method  

Example:

var
  Log: String;

  {set up table component}

  ABSTable1.DatabaseName := 'emp_db'
;
  ABSTable1.TableName := 'employee'
;
  
  {fill in restructure properties}

  ABSTable1.Open;
  ABSTable1.Close;

  with ABSTable1 do
   begin
     {specifying new table fields}

     with RestructureFieldDefs do
   begin
         Add('Hobby'
,aftString,30,False);
         Add('Comment'
,aftMemo,0,False);
    end;
     {specifying new table indexes}

     with RestructureIndexDefs do
       begin
         Add('idxHobby'
,'Hobby',[]);
       end;
     {restructure}

     if (RestructureTable(Log)) then
       ShowMessage('Restructure completed'
)
     else
       ShowMessage('Restructure errors: '
+Log);
   end;


Note:   See also how to alter table using SQL ALTER TABLE Command.


        © 2003 - 2017 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Jan 16, 2017