Schemacrawler not able to retrieve constraints
luigiba opened this issue · comments
Description
Hello,
I'm trying to retrieve the schema from an Oracle database.
Schemacrawler keeps complaining about errors like this: WARNING: Error executing SQL <......> java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
.
It seems that is missing some permissions on constraint tables. For instance at the beginning it was complaining about query error on table "DBA_CONSTRAINTS". So we granted permissions on this table, then this error disappeared and the same error came up but on another constraint table.
How can I fix that? Is it possible to know the list of constraint tables on which the the schemacrawler user should be granted on?
Thanks
How to Reproduce
schemacrawler --command=script --scripting-language=python --info-level=detailed --log-level=INFO --table-types=TABLE --script=script.py --output-file=.\schema.json --server=oracle --host=my_host.com --port=1234 --database=DB_NAME --schemas=SCHEMA --user=MY_USER <password provided>
Relevant log output
WARNING: Error executing SQL <SELECT
NULL AS TABLE_CAT,
PRIMARY_KEYS.OWNER AS TABLE_SCHEM,
PRIMARY_KEYS.TABLE_NAME,
PRIMARY_KEYS.CONSTRAINT_NAME AS PK_NAME,
PK_COLUMNS.COLUMN_POSITION AS KEY_SEQ,
PK_COLUMNS.COLUMN_NAME
FROM
DBA_CONSTRAINTS PRIMARY_KEYS
INNER JOIN DBA_IND_COLUMNS PK_COLUMNS
ON
PRIMARY_KEYS.CONSTRAINT_NAME = PK_COLUMNS.INDEX_NAME
AND PRIMARY_KEYS.OWNER = PK_COLUMNS.TABLE_OWNER
AND PRIMARY_KEYS.TABLE_NAME = PK_COLUMNS.TABLE_NAME
AND PRIMARY_KEYS.OWNER = PK_COLUMNS.INDEX_OWNER
INNER JOIN DBA_USERS USERS
ON PRIMARY_KEYS.OWNER = USERS.USERNAME
.....
WHERE
...
ORDER BY
TABLE_SCHEM,
TABLE_NAME,
PK_NAME,
KEY_SEQ
>
java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:626)
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:560)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1147)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:767)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:295)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:494)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:108)
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:892)
at oracle.jdbc.driver.OracleStatement.prepareDefineBufferAndExecute(OracleStatement.java:1168)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1097)
at oracle.jdbc.driver.OracleStatement.executeSQLSelect(OracleStatement.java:1422)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1305)
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:2159)
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:2114)
at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:324)
at us.fatehi.utility.database.DatabaseUtility.executeSql(DatabaseUtility.java:94)
at schemacrawler.schemacrawler.QueryUtility.executeAgainstSchema(QueryUtility.java:67)
at schemacrawler.crawl.MetadataResultSet.<init>(MetadataResultSet.java:83)
at schemacrawler.crawl.PrimaryKeyRetriever.retrievePrimaryKeysFromDataDictionary(PrimaryKeyRetriever.java:127)
at schemacrawler.crawl.PrimaryKeyRetriever.retrievePrimaryKeys(PrimaryKeyRetriever.java:69)
at schemacrawler.crawl.SchemaCrawler.lambda$crawlTables$11(SchemaCrawler.java:406)
at us.fatehi.utility.scheduler.TimedTask.call(TimedTask.java:68)
at us.fatehi.utility.scheduler.TimedTask.call(TimedTask.java:45)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: Error : 942, Position : 250, Sql = ..., Error Msg = ORA-00942: table or view does not exist
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:633)
... 26 more
### SchemaCrawler Version
16.19.11
### Java Version
11
### Operating System and Version
Windows 10
### Relational Database System and Version
Oracle
### JDBC Driver and Version
/
@luigiba I am not an Oracle expert, so I cannot advise you on how to configure Oracle. SchemaCrawler runs regular tests with the Oracle database, you can look at the relevant SchemaCrawler Oracle tests to see how the database is configured. In particular look at OracleSpecialUsersTest.