Problem wth sql statment.

Caporegime
Joined
12 Mar 2004
Posts
29,962
Location
England
I'm using the oracle application express to experiment with databases, and entering commands into the sql command processor.

But this code doesn't work.

alter table televisions
modify (resolution varchar2(9) 1366x768)

Can someone tell me what I've done wrong here?
 
Last edited:
What are you trying to do here?

It looks as if you're trying to alter the table and insert/update a row in the same command?
 
Trying to change the resolutions column to varchar2 and set the default value to 1366x768.

From the oracle website.

"To modify a column, use the SQL syntax shown. Modifying a column can include changes to a column's data type, size, and DEFAULT value."

ALTER TABLE tablename
MODIFY (column name datatype [DEFAULT expression],
column name datatype, ...
 
Something like:

Code:
alter table televisions
modify resolution varchar2(9) default '1366x768';
should work.
That's from memory, but it should be about right.

Why exactly are you storing resultion in a varchar2 field like that?
I don't know the details of your application, but wouldn't it make more sense to store horizontal and vertical resolutions separately as numbers?
It would probably make it easier to compare resolutions that way if you ever need to do that.
 
Of course, I forgot to put quotes around the 1366x768. :o

The database isn't anything serious, it's just so I can experiment with the different sql commands.
 
OK, if you're playing about with Oracle I would urge you to have a look at analytic functions.
They can be very powerful and it's a good idea to know a bit about them.
Google should bring back some useful information.
 
Back
Top Bottom