473,322 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Adding fields on the fly

I am investigating the possibility of using pgsql as the database in an application. I have some unusual requirements that I'd like to ask you all about. I apologize in advance if my terminology is a little "off", I'm not familiar with pgsql (yet).

My first requirement is that I need to be able to add new columns to any database table on the fly. By this I mean that I need this to happen interactively -- a user will drag some UI widget from here to there and boom! my application will request a new column to be added to a table, and wait for it to happen before giving visual feedback to the user. My questions are:

Is this even possible? Is ALTER TABLE supported?
If so, what performance characteristics can I expect? Compared to, say, inserting a record, can I expect this to be 10 times slower? 1000 times slower?
What does the performance depend on? Number of rows? Number of columns? Number of tables? anything else?
I'll send my other question in a separate message to keep the threads separate.

Thanks in advance,

Gail Zacharias
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #1
2 2889
Its in the docs.... Note that you will have to add the column and the
column constraints in two steps --

-- And -- When adding fields to an existing table the new field contains
null -- so you probably don't want to specify "not null" or you'll have to
go back and modify all of your "INSERT" statements on that table...

Additionally -- Unless you have a really smart application parsing
catalogs -- you'll either need to keep track of the new columns so you can
retrieve the data in them or SELECT * FROM mytable and have your application
sift through the fields...

ALTER TABLE mytable ADD COLUMN mynewcolumn datatype;
ALTER TABLE mytable ALTER COLUMN mynewcolumn SET default "TRUE";

Another trick I use when allowing users to dynamically (and usually
unwittingly) add columns to a table is to specify a comment on the column:

COMMENT ON mytable.mynewcolumn IS 'user-defined';

If you add a comment -- you can find the user-added columns in
pg_description

--
Greg Patnude / The Digital Demention
2916 East Upper Hayden Lake Road
Hayden Lake, ID 83835
(208) 762-0762

"Gail Zacharias" <gz@clozure.com> wrote in message
news:5.*******************************@127.0.0.1.. .
I am investigating the possibility of using pgsql as the database in an application. I have some unusual requirements that I'd like to ask you all
about. I apologize in advance if my terminology is a little "off", I'm not
familiar with pgsql (yet).
My first requirement is that I need to be able to add new columns to any database table on the fly. By this I mean that I need this to happen
interactively -- a user will drag some UI widget from here to there and
boom! my application will request a new column to be added to a table, and
wait for it to happen before giving visual feedback to the user. My
questions are:
Is this even possible? Is ALTER TABLE supported?
If so, what performance characteristics can I expect? Compared to, say, inserting a record, can I expect this to be 10 times slower? 1000 times
slower? What does the performance depend on? Number of rows? Number of columns? Number of tables? anything else?

I'll send my other question in a separate message to keep the threads separate.
Thanks in advance,

Gail Zacharias
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #2
Gail Zacharias writes:
Is this even possible? Is ALTER TABLE supported?
Yes. (RTFM)
If so, what performance characteristics can I expect? Compared to, say,
inserting a record, can I expect this to be 10 times slower? 1000 times
slower? What does the performance depend on? Number of rows? Number of
columns? Number of tables? anything else?


Adding a column runs in constant time.

--
Peter Eisentraut pe*****@gmx.net
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Anand | last post by:
Hi i am having trouble adding a recordset into the access database, the code seems to be working fine it passs and parses through all variables just fine without showing any errors and also when i...
6
by: Jamie Fryatt | last post by:
Hi everyone, here's what id like to do. I have a table with 2 fields, name and value I need to be able to add multiple records quickly, for example I need to add name value abc 1...
0
by: Jozef | last post by:
Hello, I have a list box that I'm adding items to. The line that adds the items is as follows; lstUserRoster.AddItem (iCount & ";" & rs.Fields(0) & ";" & rs.Fields(1) & ";" & rs.Fields(2) &...
2
by: brenda.stow | last post by:
error msg " An error occured while referencing the object. You tried to run a visual basic procedure that improperly references a property or method of an object" This msg occurs everytime I add a...
5
by: Kosmos | last post by:
I have traveled the world and the seven seas and I have yet to come up with an answer to this question.... So I'm adding an attachment to an email from access... The following is the code: ...
2
by: Kosmos | last post by:
Alright so I've got this Outlook code written in VBA in Access. The first part, which works, records information about appointment times based on the required days before notification of certain...
6
by: Mangler | last post by:
Say I have to different recordsets that have the fields: rsA.Fields.Item("A").Value ,rsB.Fields.Item("B").Value How would I add those to fields? It may be my inexperience but when I tried...
4
by: jaz215 | last post by:
hi! how do i add a record in a database without using the datacontrol and adodc. i want to rework my code to using purely codes and not being dependent on the design on vb. so far i have. Set rs...
18
omerbutt
by: omerbutt | last post by:
AJAX PROB WITH MULTIPLE RECORDS helo iam having problem in ma code will any body look out an help, i am trying t add sale record in the database and the checkthe quantity of the part slod and...
2
by: Steve | last post by:
I have zero experience with ODBC. If I have an Access frontend connected to a SQL Database using ODBC, are the tables connected like a frontend/backend Access database where the the tables you see...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.