Sql statements accepted by importing function are a subset of the overall statements of Oracle. The grammar accepts specific SQL statements, ignoring all others. Below are the accepted statements and important recommendations.
Create table
The CREATE TABLE
statement allows you to create a new table in the database. Within the column specification, you can include inline primary key (PRIMARY KEY) and foreign key (FOREIGN KEY) constraints.
Example:
CREATE TABLE "students" (
"id" NUMBER PRIMARY KEY,
"name" VARCHAR2(50),
"course_id" NUMBER REFERENCES "courses" ("id"),
);
Alter table add constraint
The ALTER TABLE
statement allows you to modify an existing table by adding primary key or foreign key constraints.
Example:
CREATE TABLE "students" (
"id" NUMBER,
"name" VARCHAR2(50),
"course_id" NUMBER
);
ALTER TABLE "students" ADD CONSTRAINT "pk_students" PRIMARY KEY ("id");
ALTER TABLE "students" ADD CONSTRAINT "fk_students_courses" FOREIGN KEY ("course_id") REFERENCES "courses" ("id");
Note: specifying more than one attribute creates a composite relation.
Example:
CREATE TABLE "students" (
"id" NUMBER,
"name" VARCHAR2(50),
"course_name" NUMBER
);
ALTER TABLE "students" ADD CONSTRAINT "pk_students" PRIMARY KEY ("id");
ALTER TABLE "students" ADD CONSTRAINT "fk_students_courses" FOREIGN KEY ("course_name","university") REFERENCES "courses" ("course_name","university");
Comment on table
The COMMENT ON TABLE statement allows you to add a custom property called "comment" to the table and set its value with the inserted comment.
Example:
COMMENT ON TABLE "students" IS 'Table containing students';
Comment on column
The COMMENT ON TABLE statement allows you to add a custom property called "comment" to the column and set its value with the inserted comment.
Example:
COMMENT ON COLUMN "students"."name" IS 'Name of the student';
Important Recommendations
Other statements are ignored: All other SQL statements not specified above will be ignored by the grammar.
Comment Syntax:
- Free text for comments must be enclosed in single quotes
' '
. - Table and column names can be enclosed in double quotes
" ", but definitely not in single quotes
.
- Free text for comments must be enclosed in single quotes
Handling Table Names in Multi-Schema Projects: Currently, the grammar does not support handling tables with the same names in multi-schema projects.
Reference Oracle Official Documentation: For further details, refer to the official Oracle documentation.