Hi - I am really new to Toad and I am looking to create a select into statement. I was told that I can add a column name into an existing table. I found some examples on how to do it but it does not appear to be working. Can someone provide me with a simple way of adding a column into an existing table. Thank you so much!
I’m not sure what you mean by “select into” statement, but here is a simple example of how you can add a column called NEW_COLUMN to a table called MY_TABLE.
alter table my_table add (new_column NUMBER);
John has already described how to add a column to a table, but SELECT INTO is totally different.
You would use this in PL/SQL when you want to extract a column or columns into some PL/SQL variables, for example:
myDeptId dept.dept_id%type; myDeptName dept.dept_name%type;
select dept_id, dept_name into myDeptId, MyDeptName from dept where dept_id = 666;
when no_data_found then -- handle execptions here;
Obviously, the dept_id will always be 666 in the above. But hopefully, you get my drift.
Sent from my Android device with K-9 Mail. Please excuse my brevity.
I think what John gave me will work… See what I want to do is add a blank column and then do UPDATE statements to update the blank column based on specifications (case when…) from another table on a claim_number. I am sure what you gave me will work too, Norm… Thank you both for your quick responses.