Skip to content

Instantly share code, notes, and snippets.

@maksadbek
Last active August 29, 2015 14:08
Show Gist options
  • Save maksadbek/01ca3b7bba681395f067 to your computer and use it in GitHub Desktop.
Save maksadbek/01ca3b7bba681395f067 to your computer and use it in GitHub Desktop.
drop table employee;
create table employee(
id numeric(7) NOT NULL default 1,
last_name varchar(25),
first_name varchar(25),
DEPT_ID numeric(7),
constraint pk_employee_id
primary key(id)
);
--alter table employee
--alter last_name type varchar(60)
--alter table employee
--drop column last_name
--alter table employee
--rename to employee2
alter table employee2
drop constraint pk_employee_id;
alter table employee2
add constraint pk_employee_uid
primary key(id)
--renaming back
alter table employee2
rename to employee;
alter table employee
add constraint fk_employee_dept_id
FOREIGN KEY(dept_id)
references department(id);
alter table employee
alter dept_id type numeric(7);
alter table department
add constraint pk_department_uid
primary key (id);
alter table employee
add salary numeric(7) not null default 0;
alter table employee
add constraint chk_employee_salary
check(salary <= 500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment