Last active
March 21, 2017 07:20
-
-
Save jacknie84/abc0b2032792081237629789b6e5dbfc to your computer and use it in GitHub Desktop.
table column name convert to camelcase property name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH CUSTOMIZATION AS ( | |
SELECT | |
UTC.TABLE_NAME AS TABLE_NAME | |
, (SELECT COMMENTS FROM USER_TAB_COMMENTS WHERE TABLE_NAME = UTC.TABLE_NAME) AS TABLE_COMMENT | |
, UTC.COLUMN_NAME AS COLUMN_NAME | |
, UCC.COMMENTS AS COLUMN_COMMENT | |
, LOWER(SUBSTR(UTC.COLUMN_NAME, 0, 1)) || SUBSTR(REPLACE(INITCAP(UTC.COLUMN_NAME), '_', ''), 2) AS PROPERTY_NAME | |
, UTC.DATA_TYPE || '(' || UTC.DATA_LENGTH || ')' AS DATA_TYPE | |
, UTC.DATA_DEFAULT | |
, UTC.NULLABLE | |
, CASE WHEN UCP.CONSTRAINT_NAME IS NOT NULL THEN 'PK' END AS PK | |
FROM | |
USER_TAB_COLUMNS UTC | |
, USER_COL_COMMENTS UCC | |
, ( | |
SELECT | |
UCOC.TABLE_NAME | |
, UCOC.COLUMN_NAME | |
, UCOC.CONSTRAINT_NAME | |
FROM | |
USER_CONS_COLUMNS UCOC | |
, USER_CONSTRAINTS UCO | |
WHERE | |
UCOC.CONSTRAINT_NAME = UCO.CONSTRAINT_NAME | |
AND | |
UCO.CONSTRAINT_TYPE = 'P' | |
) UCP | |
WHERE | |
UTC.TABLE_NAME = UCC.TABLE_NAME | |
AND | |
UTC.COLUMN_NAME = UCC.COLUMN_NAME | |
AND | |
UTC.TABLE_NAME = UCP.TABLE_NAME(+) | |
AND | |
UTC.COLUMN_NAME = UCP.COLUMN_NAME(+) | |
AND | |
UTC.TABLE_NAME = '[TABLE_NAME]' | |
ORDER BY | |
UTC.COLUMN_ID | |
) | |
SELECT * FROM CUSTOMIZATION; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment