In table three columns with 1 milion records(here there is
no sequence values) i want add one more column with
sequence values from the first how it is posible?
Answers were Sorted based on User's Feedback
Answer / shekharjchandra
Hi
That's a simple one . (if table is tab1)
1. Add column first
ALTER TABLE tab1 add col1 number ;
2. Update the col1 of tab1
UPDATE tab1 SET col1=ROWNUM.
This will populate all the rows in sequential numbers.
Hope this solves u r problem
regards
JC
| Is This Answer Correct ? | 16 Yes | 1 No |
Answer / saraswathi muthuraman
SQL> desc ts_200;
Name Null? Type
----------------------------------------- --------
A NUMBER
SQL> alter table ts_200 add b number;
Table altered.
SQL> desc ts_200;
Name Null? Type
----------------------------------------- --------
A NUMBER
B NUMBER
SQL> select * from ts_200;
A B
---------- ----------
1
3
7
3 rows selected.
SQL> update ts_200 set b=rownum;
3 rows updated.
SQL> select * from ts_200;
A B
---------- ----------
1 1
3 2
7 3
3 rows selected.
| Is This Answer Correct ? | 7 Yes | 3 No |
Answer / mohamed shahid
CREATE TABLE T AS SELECT ROWNUM AS seq,emp.* FROM emp;
| Is This Answer Correct ? | 0 Yes | 2 No |
Answer / kondeti srinivas
select rownum,tablename.* frome tablename;
| Is This Answer Correct ? | 0 Yes | 3 No |
----> There is a table T with two columns C1 and C2. The data is as below: C1 C2 1 4 2 5 3 6
Explain ddl statements in pl/sql?
what are the differences between binary and varbinary? : Sql dba
how will i became good database developer?
What is the difference between left join and right join?
What is sqlca in powerbuilder?
When is a declare statement required?
Why is nosql good?
What are different types of sql?
Does truncate need commit?
how can you see all indexes defined for a table? : Sql dba
In a PL/SQL block,which loop type should be used in a performance point of view & Why (as both loops can do the same task) 1) open - Fetch loop 2) for loop
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)