Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sql/plsql/PlSqlLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ ANCESTOR : 'ANCESTOR';
ANCILLARY : 'ANCILLARY';
AND : 'AND';
AND_EQUAL : 'AND_EQUAL';
ANNOTATIONS : 'ANNOTATIONS';
ANOMALY : 'ANOMALY';
ANSI_REARCH : 'ANSI_REARCH';
ANTIJOIN : 'ANTIJOIN';
Expand Down
25 changes: 22 additions & 3 deletions sql/plsql/PlSqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -3453,7 +3453,7 @@ table_properties
logical_replication_clause? flashback_archive_clause? physical_properties? (ROW ARCHIVAL)? (
AS select_only_statement
| FOR EXCHANGE WITH TABLE (schema_name '.')? table_name
)?
)? annotations_clause?
;

read_only_clause
Expand Down Expand Up @@ -4914,6 +4914,7 @@ alter_table_properties
| READ ONLY
| READ WRITE
| REKEY CHAR_STRING
| annotations_clause
;

alter_table_partitioning
Expand Down Expand Up @@ -5188,7 +5189,7 @@ modify_column_clauses
;

modify_col_properties
: column_name datatype? (DEFAULT (ON NULL_)? expression)? (ENCRYPT encryption_spec | DECRYPT)? inline_constraint* lob_storage_clause?
: column_name datatype? (DEFAULT (ON NULL_)? expression)? (ENCRYPT encryption_spec | DECRYPT)? inline_constraint* lob_storage_clause? annotations_clause?
//TODO alter_xmlschema_clause
;

Expand Down Expand Up @@ -5360,7 +5361,7 @@ column_definition
)? (DEFAULT (ON NULL_)? expression | identity_clause)? (ENCRYPT encryption_spec)? (
inline_constraint+
| inline_ref_constraint
)?
)? annotations_clause?
;

column_collation_name
Expand Down Expand Up @@ -7005,6 +7006,24 @@ xmlserialize_param_ident_part
| INDENT (SIZE '=' concatenation)?
;

// Annotations

annotations_clause
: ANNOTATIONS '(' annotations_list ')'
;

annotations_list
: (
ADD (IF NOT EXISTS | OR REPLACE)?
| DROP (IF EXISTS)?
| REPLACE
)? annotation (',' annotations_list)*
;

annotation
: identifier CHAR_STRING?
;

// SqlPlus

sql_plus_command_no_semicolon
Expand Down
14 changes: 13 additions & 1 deletion sql/plsql/examples/alter_table.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
ALTER TABLE test1 SPLIT PARTITION p_MAXV
AT (TO_DATE('01/01/2030', 'DD/MM/YYYY'))
INTO (partition p_2029 TABLESPACE users, partition p_MAXV) ONLINE;
INTO (partition p_2029 TABLESPACE users, partition p_MAXV) ONLINE;

ALTER TABLE fruit ANNOTATIONS (Visibility 'Everyone');

ALTER TABLE fruit ANNOTATIONS (drop Visibility);

ALTER TABLE fruit ANNOTATIONS (add Visibility 'Everyone');

ALTER TABLE fruit MODIFY (id ANNOTATIONS (Visibility 'Hidden'));

ALTER TABLE fruit MODIFY (id ANNOTATIONS (drop Visibility));

ALTER TABLE fruit MODIFY (id ANNOTATIONS (add Visibility 'Hidden'));
75 changes: 6 additions & 69 deletions sql/plsql/examples/create_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,73 +24,10 @@ CREATE TABLE emp_load (first_name CHAR(15), last_name CHAR(20), year_of_birth IN
ACCESS PARAMETERS ( FIELDS RTRIM (first_name (1:15) CHAR(15), last_name (*:+20), year_of_birth (36:39), phone (40:52), area_code (*-12: +3), exchange (*+1: +3), extension (*+1: +4)))
LOCATION ('info.dat'));

CREATE TABLE emp_load (first_name CHAR(15), last_name CHAR(20), year_of_birth CHAR(4))
ORGANIZATION EXTERNAL ( TYPE ORACLE_LOADER DEFAULT DIRECTORY ext_tab_dir
ACCESS PARAMETERS ( FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '(' and ')' LRTRIM )
LOCATION ('info.dat'));

CREATE TABLE xtab (recno varchar2(2000))
ORGANIZATION EXTERNAL ( TYPE ORACLE_LOADER DEFAULT DIRECTORY data_dir
ACCESS PARAMETERS ( RECORDS DELIMITED BY NEWLINE
PREPROCESSOR execdir:'zcat'
LOGFILE 'deptxt1.log'
BADFILE 'deptXT.bad'
FIELDS TERMINATED BY ',' MISSING FIELD VALUES ARE NULL (recno char(2000)))
LOCATION ('foo.dat.gz')) REJECT LIMIT UNLIMITED;

CREATE TABLE deptxt1 ( deptno number(2), dname varchar2(14), loc varchar2(13))
ORGANIZATION EXTERNAL ( TYPE ORACLE_LOADER DEFAULT DIRECTORY dpump_dir
ACCESS PARAMETERS ( EXTERNAL VARIABLE DATA
LOGFILE 'deptxt1.log'
READSIZE=10000
PREPROCESSOR execdir:'uncompress.sh' )
LOCATION ('deptxt1.dmp')) REJECT LIMIT UNLIMITED;

CREATE TABLE "T_XT" ("C0" VARCHAR2(2000))
ORGANIZATION EXTERNAL ( TYPE ORACLE_LOADER DEFAULT DIRECTORY DMPDIR
ACCESS PARAMETERS ( RECORDS XMLTAG ("home address", "work address", "home phone")
READSIZE 1024
SKIP 0
FIELDS NOTRIM MISSING FIELD VALUES ARE NULL)
LOCATION ('t.dat')) REJECT LIMIT UNLIMITED;

CREATE TABLE emp_load (first_name CHAR(15), last_name CHAR(20), year_of_birth CHAR(4))
ORGANIZATION EXTERNAL ( TYPE ORACLE_LOADER DEFAULT DIRECTORY ext_tab_dir
ACCESS PARAMETERS ( RECORDS DELIMITED BY '|' FIELDS TERMINATED BY ','
( first_name CHAR(7), last_name CHAR(8), year_of_birth CHAR(4)))
LOCATION ('info.dat'));

CREATE TABLE emp_load (first_name CHAR(15), last_name CHAR(20), year_of_birth CHAR(4))
ORGANIZATION EXTERNAL ( TYPE ORACLE_LOADER DEFAULT DIRECTORY ext_tab_dir
ACCESS PARAMETERS (RECORDS FIXED 20 FIELDS (first_name CHAR(7), last_name CHAR(8), year_of_birth CHAR(4)))
LOCATION ('info.dat'));

CREATE TABLE CUSTOMER_TABLE (cust_num VARCHAR2(10), order_num VARCHAR2(20), order_date DATE, item_cnt NUMBER, description VARCHAR2(100), order_total NUMBER(8,2))
ORGANIZATION EXTERNAL ( TYPE ORACLE_HIVE
ACCESS PARAMETERS (
com.oracle.bigdata.tableName: order_db.order_summary
com.oracle.bigdata.colMap: {"col":"ITEM_CNT", "field":"order_line_item_count"}
com.oracle.bigdata.overflow: {"action":"ERROR", "col":"DESCRIPTION"}
com.oracle.bigdata.errorOpt: [{"action":"replace", "value":"INV_NUM" , "col":["CUST_NUM","ORDER_NUM"]} , {"action":"reject", "col":"ORDER_TOTAL"}]
));
CREATE TABLE fruit (
id NUMERIC(9,0) PRIMARY KEY ANNOTATIONS (Visibility 'Everyone'));

CREATE TABLE "MASTERBILL"."ET$03D5D0AD0001" ("USER#", "NAME")
ORGANIZATION EXTERNAL (
TYPE ORACLE_DATAPUMP
DEFAULT DIRECTORY "DBEXPORT"
ACCESS PARAMETERS (
DEBUG = (0 , 0)
DATAPUMP INTERNAL TABLE "SYS"."KU$_USER_MAPPING_VIEW"
TEMPLATE_TABLE "KU$_USER_MAPPING_VIEW_TBL"
JOB ( "MASTERBILL","SYS_EXPORT_FULL_01",2)
WORKERID 1
PARALLEL 1
VERSION '19.3.0.0.0'
ENCRYPTPASSWORDISNULL
COMPRESSION DISABLED
ENCRYPTION DISABLED )
LOCATION ('bogus.dat')
)
PARALLEL 1
REJECT LIMIT UNLIMITED
AS SELECT X FROM "SYS"."KU$_USER_MAPPING_VIEW" KU$;
CREATE TABLE fruit (
id NUMERIC(9,0) PRIMARY KEY,
data varchar2(50))
ANNOTATIONS (Visibility 'Everyone');
Loading