I have created a table "employee" with two fields "empid" and "empname". I have inserted some records in it. Now I want to add two more fields to same table say: "empaddress" and "empContactNo".
If I add them individually I can do it.
ALTER TABLE "emp" ADD COLUMN "empaddress" varchar(40);
and
ALTER TABLE "emp" ADD COLUMN "empContactNo" numeric(10);
But if I want to add two columns together then I get errors. My query is:
ALTER TABLE "emp" ADD (COLUMN "empaddress" varchar(40), COLUMN "empConatctNo" numeric(10));
My question is:
Can we add more than one column using alter table query in database?
[Solved] BASE - ALTER QUERY to ADD COLUMN
[Solved] BASE - ALTER QUERY to ADD COLUMN
Last edited by assa on Wed Jan 10, 2018 3:59 pm, edited 1 time in total.
OpenOffice 4.1.4 and Operating System Windows 8.1
Re: BASE - ALTER QUERY to ADD COLUMN
Does
do what you want? If not, please tell us the error you get.
You may not need the double quotes.
Code: Select all
ALTER TABLE "emp" ADD ("empaddress" varchar(40), "empConatctNo" numeric(10));
You may not need the double quotes.
Edit: Note that it helps us to have the error message any time you get one. |
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.1.2; SlackBuild for 24.2.1 by Eric Hameleers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.1.2; SlackBuild for 24.2.1 by Eric Hameleers
Re: BASE - ALTER QUERY to ADD COLUMN
My error is :
1: Unexpected token: ( in statement [alter table "emp" add (]
1: Unexpected token: ( in statement [alter table "emp" add (]
OpenOffice 4.1.4 and Operating System Windows 8.1
Re: BASE - ALTER QUERY to ADD COLUMN
I suspect the syntax should not include the brackets () for HSQL
http://www.hsqldb.org/doc/guide/ch09.ht ... le-section
Code: Select all
ALTER TABLE "emp" ADD "empaddress" varchar(40), "empConatctNo" numeric(10);
Edit: Possibly misleading link |
Last edited by robleyd on Mon Dec 18, 2017 1:41 am, edited 1 time in total.
Reason: Disable possibly misleading documentation link
Reason: Disable possibly misleading documentation link
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.1.2; SlackBuild for 24.2.1 by Eric Hameleers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.1.2; SlackBuild for 24.2.1 by Eric Hameleers
Re: BASE - ALTER QUERY to ADD COLUMN
No it has the same error when i run the query:
ALTER TABLE "emp" ADD "empaddress" varchar(40), "empConatctNo" numeric(10);
Error:
1: Unexpected token: , in statement [,]
ALTER TABLE "emp" ADD "empaddress" varchar(40), "empConatctNo" numeric(10);
Error:
1: Unexpected token: , in statement [,]
OpenOffice 4.1.4 and Operating System Windows 8.1
Re: BASE - ALTER QUERY to ADD COLUMN
Welcome to the OpenOffice / LibreOffice Base forum.assa wrote:I have created a table "employee" with two fields "empid" and "empname". I have inserted some records in it. Now I want to add two more fields to same table say: "empaddress" and "empContactNo".
If I add them individually I can do it.
ALTER TABLE "emp" ADD COLUMN "empaddress" varchar(40);
and
ALTER TABLE "emp" ADD COLUMN "empContactNo" numeric(10);
But if I want to add two columns together then I get errors. My query is:
ALTER TABLE "emp" ADD (COLUMN "empaddress" varchar(40), COLUMN "empConatctNo" numeric(10));
My question is:
Can we add more than one column using alter table query in database?
I will assume, you are using, as your database backend, either:
- HSQL 1.8.0.10, which is the Embedded database
- HSQL 2.4.0, the most recent version of HSQL as of the date I am writing this
Just as an additional comment, with the words you used above, an ALTER statement is NOT a "table query", but rather a DDL statement. Therefore, it cannot be entered in in the Query section, but, rather using the Menu:Tools -> SQL...
I hope this helps, please be sure to let me / us know.
Sliderule
Re: BASE - ALTER QUERY to ADD COLUMN
http://www.hsqldb.org/doc/1.8/guide/ch09.html is the documentation for the version of HSQL which is shipped with OpenOffice and LibreOffice.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: BASE - ALTER QUERY to ADD COLUMN
Thanks. It was useful.
OpenOffice 4.1.4 and Operating System Windows 8.1