wise-coders / dbschema

DbSchema Database Designer
https://dbschema.com
67 stars 3 forks source link

Won't parse this script to create Oracle table... #10

Closed armplinker closed 4 years ago

armplinker commented 4 years ago
  1. Please check DbSchema Help / Output logs for errors.

  2. Please include the DbSchema version, operating system and used database 8.2.7 build 200205

  3. The steps to reproduce this issue Use this script to try and create 1 table TEST_app_parameter_sets to add to a blank diagram. Just creates an empty table object with no columns or anything. Huh?

(ORACLE 12)

Drop Table TEST_app_parameter_sets Purge;

Create Table TEST_app_parameter_sets As SELECT Sys_Guid() AS Parameter_Sets_Gd ,'INSPECTION' As App_Context ,Lower(TRIM(Pflds.Table_Name)) AS Table_Name ,Lower(TRIM(Pflds.Field_Name)) AS Column_Name FROM Paramtrs Pflds INNER JOIN User_Tab_Columns Utc ON Lower(TRIM(Utc.Table_Name)) = Lower(TRIM(Pflds.Table_Name)) AND Lower(TRIM(Utc.Column_Name)) = Lower(TRIM(Pflds.Field_Name)) GROUP BY Lower(TRIM(Pflds.Table_Name)) ,Lower(TRIM(Pflds.Field_Name)) ,Utc.Column_Id ORDER BY Lower(TRIM(Table_Name)), Utc.Column_Id;

Create Unique Index UNQ_TEST_APP_PARM_SETS_FC_REV On TEST_APP_PARAMETER_SETS (APP_CONTEXT, lower(table_name), lower(column_name)); -- Create/Recreate primary, unique and foreign key constraints Alter Table TEST_APP_PARAMETER_SETS add constraint PK_TEST_APP_PARM_SETS primary key (PARAMETER_SETS_GD); alter table TEST_APP_PARAMETER_SETS add constraint UNQ_TEST_APP_PARM_SETS_TC unique (APP_CONTEXT, TABLE_NAME, COLUMN_NAME);

wise-coders commented 4 years ago

We are using JSqlParser to parse SQL scripts and generate schema out of it. The library has limited functionality. Statements like this, with CREATE TABLE ... AS SELECT ... are too complicated and it contains lots of functions. Only a database engine can understand this syntax, then DbSchema can connect and reverse engineer the schema.