-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcampos.sql
61 lines (61 loc) · 1.93 KB
/
campos.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--------------
-- Sección Set
--------------
SET LINES 100
SET HEADING ON
SET VERIFY OFF
-------------------------
-- Definición de columnas
-------------------------
COLUMN CLAVE_PRIMARIA FORMAT A1
COLUMN COLUMN_NAME FORMAT A20
COLUMN TIPO FORMAT A15
COLUMN DEFECTO FORMAT A15
COLUMN COMENTARIO FORMAT A43
COLUMN COMMENTS FORMAT A69
COLUMN TABLA_FORANEA FORMAT A20
-------------
-- Parámetros
-------------
ACCEPT tabla PROMPT "Escribe el nombre de la tabla: "
PROMPT .
----------
-- Selects
----------
SELECT TABLE_NAME, COMMENTS
FROM USER_TAB_COMMENTS
WHERE TABLE_NAME = UPPER( '&&tabla' )
/
SELECT
Lower( M.COLUMN_NAME) || 'In' || ' ' ||
M.TABLE_NAME || '.' || M.COLUMN_NAME || '%TYPE'
FROM ( SELECT N.TABLE_NAME, L.COLUMN_NAME, '*' PK
FROM USER_CONS_COLUMNS L, USER_CONSTRAINTS N
WHERE L.CONSTRAINT_NAME = N.CONSTRAINT_NAME
AND N.TABLE_NAME = UPPER( '&&tabla' )
AND N.CONSTRAINT_TYPE = 'P' ) P, -- Clave primaria
USER_TAB_COLUMNS M, USER_COL_COMMENTS C
WHERE M.TABLE_NAME = C.TABLE_NAME
AND M.COLUMN_NAME = C.COLUMN_NAME
AND M.TABLE_NAME = P.TABLE_NAME (+)
AND M.COLUMN_NAME = P.COLUMN_NAME (+)
AND M.TABLE_NAME = UPPER( '&&tabla' )
AND M.COLUMN_NAME not like '%AUD%'
ORDER BY M.COLUMN_ID
/
SELECT '* @param ' ||lower( M.COLUMN_NAME )|| 'In'
FROM ( SELECT N.TABLE_NAME, L.COLUMN_NAME, '*' PK
FROM USER_CONS_COLUMNS L, USER_CONSTRAINTS N
WHERE L.CONSTRAINT_NAME = N.CONSTRAINT_NAME
AND N.TABLE_NAME = UPPER( '&&tabla' )
AND N.CONSTRAINT_TYPE = 'P' ) P, -- Clave primaria
USER_TAB_COLUMNS M, USER_COL_COMMENTS C
WHERE M.TABLE_NAME = C.TABLE_NAME
AND M.COLUMN_NAME = C.COLUMN_NAME
AND M.TABLE_NAME = P.TABLE_NAME (+)
AND M.COLUMN_NAME = P.COLUMN_NAME (+)
AND M.TABLE_NAME = UPPER( '&&tabla' )
AND M.COLUMN_NAME not like '%AUD%'
ORDER BY M.COLUMN_ID
/
SET VERIFY ON