Home » SQL & PL/SQL » SQL & PL/SQL » sql query doubt
sql query doubt [message #211136] Tue, 26 December 2006 12:38 Go to next message
Messages: 38
Registered: December 2006
i created a table eg,
sql>create table emp(c_name varchar2(22), gender char(2));
table created

sql>desc emp;
name null? type
----- ------------
c_name varchar2(22)
gender char(2)

doubt 1:
Is it possible to add a new column where ever we want in a existing table. If so How ?

i mean for eg, i like to add a column c_id before the column c_name

doubt 2:
i inserted some values to the above created table emp;
when i gave the command
select * from emp;
c_name ge
------------------- --
aaa 22
bbb 25

is it possible to display the column gender as gender not like ge?

doubt 3:
how to give check constraints for datatype date, the entering data should not exceed the current system date or user define date

doubt 4:
c_name ge custid
------------------- -- -------
aaa m 00sb1
00sb2 m bbb
aaa m

in above eg i like to remove the 3rd duplicate row
i tried with rowid it works, but is there any other way to delete the 3rd row without using rowid or rownum;

also i wrongly entered the values in 2nd row
i like to interchange the values is it possible
or we have use rowid;

Re: sql query doubt [message #211139 is a reply to message #211136] Tue, 26 December 2006 12:55 Go to previous messageGo to next message
Messages: 24958
Registered: January 2009
Location: SoCal
Senior Member
All the answers can be found by reading the fine SQL Reference manual found at http://tahiti.oracle.com
Re: sql query doubt [message #211143 is a reply to message #211136] Tue, 26 December 2006 13:29 Go to previous message
Messages: 20847
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
This will give you some hints, so that you'd know WHAT to search for while on Tahiti.
  1. No, it isn't possible. New columns are added at the end of a table. If you want to reorder it, drop the table and create it again. Or, much easier, name all columns in SELECT statement in any order you wish.
  2. Use COLUMN SQL*Plus command to format the column accordingly to your needs, or enclose column alias into double quotes.
  3. Constraits can be created either in CREATE TABLE, or later using ALTER TABLE command.
  4. Go to OraFAQ homepage, go to the "FAQ" section and search for this subject. Or, use this Forum's Search facility to do the same.
  5. "Interchanging" values doesn't mean anything in relational database. Records do not have any particular order unless you select them using an ORDER BY clause.
Previous Topic: ORA-01722
Next Topic: Mathematical Theory of Structured Query Language?
Goto Forum:

Current Time: Mon Oct 24 05:40:52 CDT 2016

Total time taken to generate the page: 0.06237 seconds