473,725 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ALTER TABLE requires extra parentheses for Oracle?

Seems that Oracle 9.2 (using MS ODBC driver) requires extra
parentheses when adding multiple columns to a table:

ALTER TABLE MyTable ADD (MyColumn1 VARCHAR(255), MyColumn2
VARCHAR(255))

vs

ALTER TABLE MyTable ADD MyColumn1 VARCHAR(255), MyColumn2 VARCHAR(255)

The former simply doesn't work with MS Access or SQL server. I'm
wondering what the SQL standard is, and whether there is a way (other
than adding columns one at a time, which is surely inefficient for a
table with existing data) of writing the statement to work with all 3
types of database.

TIA

Dylan
Jul 19 '05 #1
2 9836

"Dylan Nicholson" <wi******@hotma il.com> wrote in message
news:7d******** *************** ***@posting.goo gle.com...
Seems that Oracle 9.2 (using MS ODBC driver) requires extra
parentheses when adding multiple columns to a table:

ALTER TABLE MyTable ADD (MyColumn1 VARCHAR(255), MyColumn2
VARCHAR(255))

vs

ALTER TABLE MyTable ADD MyColumn1 VARCHAR(255), MyColumn2 VARCHAR(255)

The former simply doesn't work with MS Access or SQL server. I'm
wondering what the SQL standard is, and whether there is a way (other
than adding columns one at a time, which is surely inefficient for a
table with existing data) of writing the statement to work with all 3
types of database.

TIA

Dylan


The driver might be "editing" your sql statements for you. Try a pass thru
query. Also usually for variable characters in Oracle you should use
varchar2 not varchar. The extra parens should be ignored in any database
since they are just a grouping mechanism.
Jim
Jul 19 '05 #2
wi******@hotmai l.com (Dylan Nicholson) wrote in message news:<7d******* *************** ****@posting.go ogle.com>...
Seems that Oracle 9.2 (using MS ODBC driver) requires extra
parentheses when adding multiple columns to a table:

ALTER TABLE MyTable ADD (MyColumn1 VARCHAR(255), MyColumn2
VARCHAR(255))

vs

ALTER TABLE MyTable ADD MyColumn1 VARCHAR(255), MyColumn2 VARCHAR(255)

The former simply doesn't work with MS Access or SQL server. I'm
wondering what the SQL standard is, and whether there is a way (other
than adding columns one at a time, which is surely inefficient for a
table with existing data) of writing the statement to work with all 3
types of database.


Dylan,

According to the current SQL standard, SQL-2003, you may only add one
column per ALTER TABLE statement:

<alter table statement>::=AL TER TABLE <table name> <alter table
action>

<alter table action>::=
<add column definition>
|<alter column definition>
|<drop column definition>
|<add table constraint definition>
|<drop table constraint definition>

<add column definition>::=A DD [ COLUMN ] <column definition>

The SQL-99 and SQL-92 standards specified ALTER TABLE ADD COLUMN the
same way as above.

The SQL-89 standard allowed a form of ALTER TABLE that specified
several columns in parentheses. Just like your first example.
To verify SQL standard compliance, you can use the SQL Validator:
http://developer.mimer.com/validator/
HTH,
Jarl
Jul 19 '05 #3

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

Similar topics

8
41692
by: Maximilian Scherf | last post by:
Hello, I have two problems with the ALTER TABLE command (Warning: I'm not exactly an Oracle expert): First Problem: I want to change the name of a column. I've tried the following: ALTER TABLE <table_name> RENAME COLUMN <old_column_name> TO <new_column_name>;
1
2956
by: FRED | last post by:
hi all, i have a table that has a column date varchar(20) and now i learned some more about mysql I want to make it date date but if I do an alter table on it what will it do to my existing data which currently is in the format 11 June 2004 (but in a varchar type). many thanks! F
3
22637
by: Prince Kumar | last post by:
Is there any way I can define an Unique constraint or unique index which allows more than one null values for the same column combination in DB2? ie, If my index is defined on (col3, col4) where both columns allow nulls, I want col3 + col4 to be unique, if one or both the columns have values. If both columns have nulls, it should allow more than one such rows. ex,
4
5874
by: maricel | last post by:
Could someone confirm which tablespace is being used when running ALTER & CREATE INDEX. Is it the tempspace or the tablespace where the table resides? Many thanks, maricel
4
3913
by: Jeff Kish | last post by:
Hi. I have a database I need to supply something (I'm assuming a t-sql script.. maybe something else is better) to update customer tables with. The operations include mostly changing varchar lengths, though a couple of columns were renamed. I'd like to maybe figure out how to get Enterprise Manager or Query Analyzer to generate the scripts.
117
18548
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of elements in the HTML to get everything just right. When you consider the class attribute on the DIV elements, there's not much size savings anymore for using DIV. There are other disadvantages to not using TABLE/TR/TD, such as the lack of ability...
1
3511
by: vasilip | last post by:
I'm testing out db2 for a project I'm starting that requires proper xml support and I can't seem to get both xml and spatial data to work well in the same table. Once having created a table containing both xml and spatial data fields I can't seem to find a way to alter the table I have created a table containing an id, xmldata field and a ST_Point If I try to drop the xml field with ALTER TABLE TEST DROP COLUMN
6
7354
by: Barry | last post by:
In sqlserver 2000 I have a UDF which works fine but I want to make a change to it. When I do an ALTER FUNCTION ... I get an error saying that I can't alter the function because it is referenced by an object. Is there any way around this? I reference the UDF in over 100 tables, do I have to go to each table, remove the all references alter the function then edit each 100 tables again? How clumsy can it be? Barry
2
175
by: Dylan Nicholson | last post by:
Seems that Oracle 9.2 (using MS ODBC driver) requires extra parentheses when adding multiple columns to a table: ALTER TABLE MyTable ADD (MyColumn1 VARCHAR(255), MyColumn2 VARCHAR(255)) vs ALTER TABLE MyTable ADD MyColumn1 VARCHAR(255), MyColumn2 VARCHAR(255)
0
8888
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
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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
9257
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
9174
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
8096
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
4517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4782
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2157
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.