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 |
How to use distinct and count in sql query? Explain
What is an exception in pl/sql?
What is sql profiler in oracle?
How to use sql*plus built-in timers?
What is a system versioned table?
What are the various restrictions imposed on view in terms of dml?
What is on delete restrict?
what is a scheduled jobs or what is a scheduled tasks? : Sql dba
SELECT emp_num, years, SUM(salary) FROM sales UNION ALL SELECT emp_id, SUM(takehomepay) FROM marketing What error is present in the sample code above? 1. Queries being combined with the UNION ALL statement are not allowed to have SELECT lists with a different number of expressions. 2. You are not allowed to use aggregate functions within two queries joined by a UNION ALL statement. 3. The UNION ALL statement incorrectly combines the "years" result from the first query with the "SUM (takehomepay)" result from the second query. 4. Unless the UNION ALL statement is replaced with a UNION statement, the queries will return duplicates. 5. The "emp_id" column from the second query must be renamed (or aliased) as "emp_num" so that it corresponds to the column name from the first query. Otherwise, the queries will not execute.
What is string join?
What is a column in a table?
What is procedure function?