473,671 Members | 2,510 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2912
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.mynewco lumn 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
2582
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 access the recordset it displays the results, what the real issue is that the entry is not made into the database even though i use the Update command and i have also tried the BeginTrans and CommitTrans nothign seems to work and i am unable to...
6
2404
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 abc 2 abc 3
0
1352
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) & ";" & rs.Fields(3)) There are items in field index 1,2 and 3, but they don't show up in the
2
5780
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 new record to a subform. If I close msgbox I can then successfully add new record. Have looked on MS Technet and tried their 2 suggestions:- 1)LinkChildFields property contains the name of a form property - this isn't the case linkChildFields...
5
5355
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: and from here I go to the end (because the other part is in an If statement and that's in a loop...once the loop's finished, I've gathered the necessary information I would paste the full function but I already have in another place on this site and...
2
3664
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 contracts and then it adds them to the outlook calendar of the current user. This code works and is nested within a bunch of if statements because it only needs to trap certain appointments. The table I create with this code is later used to attempt to...
6
1581
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 something like rsA.Fields.Item("A").Value + rsB.Fields.Item("B").Value didnt work because one of the fields was a empty value. I have about 6 fields i need to add together if a value exists in any of them.
4
7835
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 = New ADODB.Recordset Set con = New ADODB.Connection con.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=C:\Program Files\Logsheet\Logsheet.mdb;" con.Open rs.Open "SELECT * from Employee;", con,...
18
1966
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 decrement it to the current quantity for example if tehre is a part woth part no 10023 and its quantity in show room is 20 and total quantity is 25 then if there is a sale of 2 parts then i have to add the sale and decrement the current quantity in the...
2
3734
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 in the frontend are only "copies" of the tables in the backend? Or ar the tables "real" tables connected to the SQL tables in some manner? If the latter, can an Access table have more fields than the SQL table it is linked to? The reason for my...
0
8478
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8919
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8821
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8599
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4409
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.