Modifying database table structure 
Author Message
 Modifying database table structure

I am a relatively new user of delphi and Database utilities so please
excuse my lack of knowledge. I was wondering if someone could explain if
and how to change a tables structure programmaticaly. What I want to do
is add columns for weekly entries from a group of charitable
contributors. The exact date is not known ahead of time so the column
heading needs to be changed. Also the exact number of columns per month
is not known ahead of time but once they are entered I would like to use
the date entered as the column reference. Thanks for any assistance.



Mon, 22 Feb 1999 03:00:00 GMT  
 Modifying database table structure



Quote:
> I am a relatively new user of Delphi and Database utilities so please
> excuse my lack of knowledge. I was wondering if someone could explain
> if and how to change a tables structure programmaticaly. What I want
> to do is add columns for weekly entries from a group of charitable
> contributors. The exact date is not known ahead of time so the column
> heading needs to be changed. Also the exact number of columns per
> month is not known ahead of time but once they are entered I would
> like to use the date entered as the column reference. Thanks for any
> assistance.> .

Using SQL it is very easy.  You will use a TQuery component and modify
the SQL property either at design time or run-time with the ALTER TABLE:

ALTER TABLE table ADD column_name data_type [, ADD column_name data_type
..]

Ex.  Alter Table 'mytable.dbf' Add NewColumn char[30]

To add this at run-time:

Query1.SQL.Clear;
Query1.SQL.Add('ALTER TABLE mytable Add NewColumn char[30]');

To run your query

Query1.Prepare;
Query1.ExecSQL;

Hope this helps and God Bless,

--

09/05/96 22:54
---------
Using: OUI PRO 1.5.0.2 from http://www.dvorak.com



Tue, 23 Feb 1999 03:00:00 GMT  
 Modifying database table structure

 I was wondering if someone could explain if and how to change a
 tables structure programmaticaly. What I want to do is add columns
 for weekly entries from a group of charitable contributors. The exact
 date is not known ahead of time so the column heading needs to be
 changed. Also the exact number of columns per month is not known
 ahead of time but once they are entered I would like to use the date
 entered as the column reference. Thanks for any assistance.

--

It sounds like you are trying to develop this application, based upon
a spreadsheet model. This is probably not the ideal way to store info
in a database; many databases have limits on how many columns you can
have, adding columns may be very slow, may be impossible to do within
a transaction, and may prevent other users accessing the data.

It sounds like you need:
- A table listing each contributor
  - name
  - details
- A table listing each contribution
  - who from
  - amount
  - date

Your can then analyze the contribution table by date, contributor
for reporting purposes.

Hope this helps

Thomas



Sun, 28 Feb 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. modifying database structure from Delphi

2. Modify Field Structure in Table

3. How to modify table structure ?

4. Is there a CODE way to modify a table structure without DESKTOP

5. Problems modifying table structures

6. Utility to display structure of database tables?

7. Want tools to print tables structure and index seen on Database Explorer

8. Changing of structure Paradox-tables (Table Language)

9. Creating Empty Table with Structure of existing table

10. MODIFY/ADD FIELD TO PDOX TABLE WITH DELPHI

11. HELP : How to modify a populated Table structure in D2 ?

12. How to lock a table of Interbase to avoid that others modify it

 

 
Powered by phpBB® Forum Software