PL/SQL :: How To Find Which Sequence Name Used In A Table - Redux

Sep 9, 2013

Beginning with 12c, there is now a way to associate a sequence with a table.  It's a new feature called an Identity column. 

create table t
(some_id number generated as identity --< creates a system generated sequence
,name varchar2(30)
); 
insert into t (name) values ('Smith');
insert into t (name) values ('Jones');

[code]....

View 7 Replies


ADVERTISEMENT

PL/SQL :: How To Find Sequence For A Table

May 14, 2013

I've got plenty of sequences. How can I identify that what are the sequences acting on a table?

View 8 Replies View Related

SQL & PL/SQL :: Find If Sequence Was Reset

Sep 26, 2010

In oracle is it possible to find if a sequence was reset? I know my sequence was reset, looking at the nextval of my sequence, but is there an oracle log or anything which proves that sequence was reset ?

View 2 Replies View Related

SQL & PL/SQL :: Insert Into Table Without Using Sequence ID

Apr 9, 2012

Is it possible to insert new id without sequence id.

For e.g. :

1 , 'BOLT'
2 , 'CHAIN'

i need to insert 3rd and 4th row as

3 , 'screw'
4 , 'driver'

without using sequence (autonumber gen).

View 11 Replies View Related

SQL & PL/SQL :: Table Creation With First Column To Be Sequence

May 6, 2010

I want to create a table, whose first column , patient_id, should be a sequence.

View 9 Replies View Related

SQL & PL/SQL :: Assign Sequence Name During Table Creation?

Aug 22, 2011

is it Possible to Assign the Sequence Name During the Table Creation.

View 1 Replies View Related

SQL & PL/SQL :: Rows In Table With Sequence Number

May 17, 2012

I have a table ABC with two columns NAME and SEQUENCE. The valid values of sequence are from 1..50. The table may not have all the Sequence number. For example following is the data in my table..

Quote:NAME SEQUENCE
------------------------
Jonh| 5
Amy| 1
Suresh| 3

I need a SQL to get the data like

Quote:NAME SEQUENCE
------------------------
Amy| 1
| 2
Suresh| 3
| 4
Jonh | 5
|6
|7
..
..
..
|50

Basically I want to have rows for the sequence numbers which are not present i my table. I thought of using the following query to generate a sequence and then join, but does not work.

select rownum from dual connect by rownum <=50

I tried something like

with temp as (select name, sequence from abc where supp_ref_order is not null order by sequence )
select rownum as num, temp.name from dual, temp connect by rownum <=50 where temp.sequence =num

View 12 Replies View Related

How To Add Sequence Column To Existing Table With Records

Dec 8, 2012

I had created a new table named USERLOG with two fields from a previous VIEW. The table already consist of about 9000 records. The two fields taken from the VIEW, i.e. weblog_views consist of IP (consists of IP address), and WEB_LINK (consists of URL). This is the code I used,

CREATE TABLE USERLOG
AS
SELECT C_IP, WEB_LINK FROM weblog_views;

I want to add another column to this table called the USER_ID, which would consists of a sequence starting with 1 to 9000 records to create a unique id for each existing rows. I'm using Oracle SQL Developer: ODMiner version 3.0.04. I tried using the AUTO-INCREMENT option,

ALTER TABLE USERLOG
ADD USER_ID INT UNSIGNED NOT NULL AUTO_INCREMENT;

But I get an error with this,

Error report:
SQL Error: ORA-01735: invalid ALTER TABLE option
01735. 00000 - "invalid ALTER TABLE option"

View 2 Replies View Related

SQL & PL/SQL :: How To Add Sequence Column To Existing Table With Records

Dec 8, 2012

I had created a new table named USERLOG with two fields from a previous VIEW. The table already consist of about 9000 records. The two fields taken from the VIEW, i.e. weblog_views consist of IP (consists of IP address), and WEB_LINK (consists of URL). This is the code I used,

CREATE TABLE USERLOG
AS
SELECT C_IP, WEB_LINK FROM weblog_views;

I want to add another column to this table called the USER_ID, which would consists of a sequence starting with 1 to 9000 records to create a unique id for each existing rows. I'm using Oracle SQL Developer: ODMiner version 3.0.04.

I tried using the AUTO-INCREMENT option,

ALTER TABLE USERLOG
ADD USER_ID INT UNSIGNED NOT NULL AUTO_INCREMENT;

But I get an error with this,

Error report:
SQL Error: ORA-01735: invalid ALTER TABLE option 01735. 00000 - "invalid ALTER TABLE option"

View 4 Replies View Related

SQL & PL/SQL :: How To Identify Specific Sequence Name Applied On A Table

Mar 1, 2011

How to identify the specific sequence name applied on a table.

View 4 Replies View Related

PL/SQL :: Update Duplicate Records In Table With Sequence Value

Mar 25, 2013

My table have duplicate records. I want to impose a primary key on that table. For that I have to replace duplicate values of a column with next value of a sequence.

View 2 Replies View Related

PL/SQL :: How To Insert Sequence Numbers In A Table Column

Aug 23, 2012

I am having the emp table :

empno enmae job
1111 ramu S.E
7658 VENU S.S.E
8280 GETA TRAINEE

alter table emp add sno number

for that sno i have to generate 1,2,3,...

View 4 Replies View Related

PL/SQL :: Update Table Column Using Complex Sequence

Feb 6, 2013

I use a sequence to generate an alphanumeric code and I need to update all rows of a table with that sequence. The sequence is created with this code:

SELECT (CHR(TRUNC(s.nextval/1000) + ASCII('A')) || LTRIM(TO_CHAR(MOD(s.currval,1000),'099'))
FROM dual;

I have tried many things - most recently

Update t3_temp_table
SET mergecode =
SELECT (CHR(TRUNC(s.nextval/1000) + ASCII('A')) || LTRIM(TO_CHAR(MOD(s.currval,1000),'099'))
FROM dual;

I get missing expression error.

It works fine if I use a straight s.nextval

View 5 Replies View Related

SQL & PL/SQL :: Finding Next Record In Cyclic Order In Table Using Sequence

Sep 4, 2010

I have a table as below:-

CREATE TABLE TEST_EMP_WIP
(
EMP VARCHAR2(20 BYTE),
WIP NUMBER,
MAX_SEQUENCE NUMBER
)

[Code]....

EMP WIP MAX_SEQUENCE RANK
002 2 2 1
003 1 4 2
005 3 5 3
010 1 4
011 1 5

I have to find the next EMP whose MAX_SQUENCE needs to be updated with a sequence. In this case the next would be '010' I fetched the EMP who falls after the max value of the column max_sequence in order of EMPCODE.

select emp_next from (
SELECT emp,max_sequence, LEAD(emp, 1, 0) OVER (ORDER BY emp) AS emp_next
from test_emp_wip where wip > 0 )
where max_sequence=(select max(max_sequence) from test_emp_wip where wip > 0)
EMP_NEXT
010
After sometime, the record would look like :-

EMP WIP MAX_SEQUENCE RANK
002 2 2 1
003 1 4 2
005 3 5 3
010 1 6 4
011 1 7 5

Now the next update should be done to the EMP '002' in cyclic manner.

tell me a way to do this. I can insert new columns if needed in table for calculation.

View 5 Replies View Related

SQL & PL/SQL :: Using Sequence To Insert In Child Table Group By A Counter Column

Oct 1, 2011

I found nothing in SQL (all in PL/SQL).I have a table:

create table Parent (pk_id number primary key); --which is filled using sequence seq_Parent.

And I have a child table:

create table Child (rRef number, fk_parent number primary key (rRef, fk_parent);

that I need to insert into Child using seq_parent but I want to insert the same sequence for each group of rRef. I dont know how to do that using SQL not PL/SQL.

View 7 Replies View Related

SQL & PL/SQL :: How To Get Left Padded Sequence Values In Variable To Insert It In Table For ID Creation

Feb 22, 2010

I have a stored proc SP_INSERT_TRAINEES.Here sTraineeNo is provided as input which has count of trainee needs to be inserted in table aaa_foc.user_profile. The sequence is used to generate ids as :

CREATE SEQUENCE AAA_FOC.TRAINEE_ID INCREMENT BY 1 MINVALUE 0 MAXVALUE 999 NOCACHE NOCYCLE NOORDER

I want the values for ids to be inserted as 001,002,003,.......010,011,................099,100,101,............999.So that the values in the table would be like TRAINEE001,002.......

I have tried to use LPAD to it but the values are getting insertes as TRAINEE1,2,3...........

The code is given below:

CREATE OR REPLACE PROCEDURE AAA_FOC9.SP_INSERT_TRAINEES
(sTraineeNo IN NUMBER,
nReturned_O OUT NUMBER)
IS
ln_insert_cnt PLS_INTEGER :=0;
nSequence NUMBER:=0;
[code]......

View 2 Replies View Related

How To Find Table Fragmentation

Jul 22, 2011

A query to find the table fragmentation.

View 1 Replies View Related

How To Find Table For Script

Aug 19, 2010

i have table like TWRCHAIN_WS_SUM. it is regularly updated by another object like procedure, function. how can i find which object is updating the particular table across the database.

View 4 Replies View Related

Unable To Find A Table?

Mar 22, 2011

why am i getting this?

SQL> SELECT TABLE_NAME,owner from dba_TABLES where TABLE_NAME in ('BSNL_ACCOUNT_DATA','BSNL_SERVICE_DATA','BSNL_PKG_DETAILS');

TABLE_NAME OWNER
------------------------------ ------------------------------
BSNL_ACCOUNT_DATA BPREAD
BSNL_SERVICE_DATA BPREAD

but the table exists

SQL> select count(*) from BPREAD.BSNL_PKG_DETAILS;

COUNT(*)
----------
3704

SQL> select TABLE_NAME,owner from dba_TABLES where TABLE_NAME='BSNL_PKG_DETAILS';

no rows selected

why is it showing no rows even if the table exists

View 3 Replies View Related

Find Out Row Count From Each Table?

May 6, 2009

I have written a script to get count of each tables of a schema.

DECLARE CURSOR c1 IS
select distinct table_name from all_tab_columns where OWNER='PLAY';
countrows NUMBER;

[Code].....

View 1 Replies View Related

Find Out Row Count From Each Table

Mar 31, 2009

SQL> select count(*) from tab;
COUNT(*)
----------
63

I need to find out how many rows in each table.I've tried with cursor.

View 9 Replies View Related

SQL & PL/SQL :: How To Find Table That Contains Certain Column

Nov 9, 2011

To find out column in which table it is located.

View 1 Replies View Related

SQL & PL/SQL :: How To Find Table And Column Name

May 14, 2013

With Data in a table, is it possible to find out the table name and column name? Means i know the account number (data) of the table and with this data i want to find out column name and table name.

View 3 Replies View Related

SQL & PL/SQL :: Find Constraint Name Of A Table

Dec 24, 2010

I want to know constraint name of a particular table if it exists.Here are the queries that i tried to find the constraint name of a particular table but the results were 'no rows selected'.

Queries:

select constraint_name from user_cons_columns where table_name='x';
select constraint_name from user_constraints where table_name='x';

View 5 Replies View Related

SQL & PL/SQL :: How To Find Which Table Is Last Updated

Apr 11, 2012

I want to know that How to find which table got last updated and how to find last DDL and DML operation obtained in which table? here I know the table name

SQL> SELECT LAST_DDL_TIME FROM DBA_OBJECTS WHERE OBJECT_NAME='PREM';

LAST_DDL_
---------
20-MAR-12

SQL> TRUNCATE TABLE PREM;

Table truncated.

SQL> SELECT LAST_DDL_TIME FROM DBA_OBJECTS WHERE OBJECT_NAME='PREM';

LAST_DDL_
---------
10-APR-12

Note: With out enable the auditing I want to know that .

View 6 Replies View Related

SQL & PL/SQL :: Find Out Duplicate Name From Table?

Oct 28, 2010

i have a employee table .i want to find out duplicate name from this table.so i write following query

select empname from employee
having count(empname) >1
group by empname

i find the result but problem is how i can find out the same name if it have any space like ramkumar ram kumar both are same but above query did not.give this data. how i can solve it

View 16 Replies View Related

SQL & PL/SQL :: How To Find Out Wrong Value From Table

Jan 13, 2011

I've written the code (see below) and after run I get an error:

ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bind

I don't know how to find out the wrong value from table. How to find it out?

DECLARE
TYPE rowids IS TABLE OF ROWID;
r1 rowids;
type t_varchar is table of varchar2(50);
n1 t_varchar ;

cursor c1 is select e.rowid rid,msisdn_displayed
from the_table
where contract_id is not null;
BEGIN
OPEN c1;
[code].........

View 3 Replies View Related

PL/SQL :: How To Find Max Date From A Table

Mar 2, 2013

I have two table in the database. I want to find the maximum routine date for a case_id when the lock_date is between 20 jan to 29 jan 2012 .

But I am not getting actual output (Output routine_date should be "28-jan-2012" but I m getting "31-jan-2012")

Master
case_id lock_date
101 23-jan-2012
101 24-jan-2012
102 27-jan-2012
102 29-jan-2012
101 30-jan-2012
101 29-jan-2012

Routine (for routine work)
case_id routine_date
101 23-jan-2012
103 28-jan-2012
102 21-jan-2012
102 29-jan-2012
101 21-jan-2012
101 28-jan-2012
101 31-jan-2012

select m.case_id, r.routine_date from master m, routine r,
(select case_id, max(routine_date) from routine group by case_id) rr

where m.case_id=r.case_id
and m.case_id=rr.case_id
and r.routine_date=rr.routine_date

View 7 Replies View Related

Find Special DML On A Table

Apr 12, 2013

i'm just trying to find out DML Statements, that where executed on a special table at a defined time. By googeling i just found a statement to find out the last DML, that was executed on a table or something else. But i want to look into the past. How can i do this?

View 16 Replies View Related

How To Find Last Inserted Record In A Table

Oct 5, 2010

I have a table where there is no sequence maintained and there is no time stamp column to track the inserted record.How do I find the latest inserted record in the table.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved