distal-attribute
distal-attribute
distal-attribute
distal-attribute

insert records into newly added coulumns of existing table.

danamma123 posted 9 months ago in General
Hi all,
I want to add new columns and insert some records(withou affecting existing columns) into those coulumns with existing table.. can any one help me out for this.
jfalch posted 9 months ago
add new columns: select table in the tree on the left; click on "Table" tab on the upper right; click on Columns: "Add" button in the middle right.

insert records: select table in the tree on the left; click on "Data" tab on the upper right; in the button panel on top, click "Last" button ( >| ), then click "Insert" button ( + ). Enter first field, press tabe, secosnd field, ...; when finished with fields, press Enter.
danamma123 posted 9 months ago
Hi jfalch, thanks for ur reply.. i needed dynamic sql querry. can u please help me out for the required..
jfalch posted 9 months ago
add new columns: cf ALTER TABLE ADD COLUMN ....

modify existing records, set new columns only: generate appropriate UPDATE statements where the SET clause specifies only the new columns. You must have an unique key in the existing records for this to work - eg generate
UPDATE yourtable SET newcol1=value1, newcol2=value2 ... WHERE keyfield=keyvalue
for each existing record.
danamma123 posted 9 months ago
if there only few a records then i can use "UPDATE" cluase. But if there are millions of records exists in that table, its not the perfect way to write "UPDATE" cluase for all records.
jfalch posted 9 months ago
AFAIK there is no other way. if you want to change existing records, you have to use UPDATE; the only alternative that I could think of is: you could export the table (using INSERTs), and then modify every INSERT line in the exported file with a program (appending new column values before the ')' at the end of each INSERT clause), then TRUNCATE the table, and load the modified import file.

Please login to leave a reply, or register at first.