Analyzing DDL statement

Analyze create table statement, extract table name, attribute names, data types, fetch Primary Key, Foreign Key, Unique Columns.

Here is a create table statement:

create table new_employees
(
	employee_id  number primary key,
	first_name  varchar2(15) null,
	last_name varchar2(15) check(last_name>10),
	hire_date date default sysdate,
	dept_id number,
	dept_name varchar2(100),
	start_date timestamp(7) references scott.dept(start_date),
	end_date timestamp(7)   references dept.end_date on delete cascade,
	check (start_date>end_date),
	constraint c_name unique(first_name,last_name),
	foreign key(dept_id,dept_name) references dept(id,name)
);

Generate the following result by running “analyzing DLL” demo(Java version, C# version) against above SQL.

Table Name:new_employees
Columns:
	name:employee_id
	datetype:number
	inline constraints:
		primary key

	name:first_name
	datetype:varchar2(15)
	null: yes

	name:last_name
	datetype:varchar2(15)
	inline constraints:
		check:last_name>10

	name:hire_date
	datetype:date
	default:sysdate

	name:dept_id
	datetype:number

	name:dept_name
	datetype:varchar2(100)

	name:start_date
	datetype:timestamp(7)
	inline constraints:
		foreign key
		referenced table:scott.dept
		referenced columns:start_date

	name:end_date
	datetype:timestamp(7)
	inline constraints:
		foreign key
		referenced table:dept.end_date

	outline constraints:
		check:start_date>end_date

		constraint name:c_name
		unique key
		columns:first_name,last_name

		foreign key
		columns:dept_id,dept_name
		referenced table:dept
		referenced columns:id,name

Download this demo: Java version, C# version