Det finns data_precision
och data_scale
kolumner där.
Ta en titt på det här exemplet:
create table qwer(
x number,
y number(8,2),
z number(5,0),
a int,
b decimal(5,3)
);
SELECT column_name, data_type, data_precision, data_scale
FROM USER_TAB_COLUMNS
WHERE Table_name = 'QWER'
;
COLUMN_NAME DATA_TYPE DATA_PRECISION DATA_SCALE
------------- --------- -------------- ----------
B NUMBER 5 3
A NUMBER
X NUMBER
Y NUMBER 8 2
Z NUMBER 5 0
REDIGERA
För att hitta primärnyckelkolumner måste du ansluta till två ordboksvyer, se exemplet nedan:
CREATE TABLE pk1(
id int primary key,
name varchar2(10)
);
CREATE TABLE pk2(
id int ,
pk1 number(10,0),
pk2 varchar2(5),
name varchar2(10),
constraint my_composite_pk primary key (id, pk1, pk2 )
);
SELECT c.table_name, cols.column_name, cols.position
FROM user_constraints c
JOIN USER_CONS_COLUMNS cols
USING ( CONSTRAINT_NAME )
WHERE c.table_name IN ('PK1', 'PK2' )
and c.constraint_type = 'P' /* P - means PRIMARY KEY */
ORDER BY 1,3
;
TABLE_NAME COLUMN_NAME POSITION
---------- ----------- ----------
PK1 ID 1
PK2 ID 1
PK2 PK1 2
PK2 PK2 3