0% found this document useful (0 votes)
114 views21 pages

Soal Latihan Prakti Oracle Menggunakan SQL Developer

The document provides instructions for creating database tables, inserting data, and defining foreign key constraints for an banking database schema using Oracle SQL Developer. It includes steps to create tables for accounts, transactions, branches, employees, customers and more. Data is then inserted into the department, branch and employee tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
114 views21 pages

Soal Latihan Prakti Oracle Menggunakan SQL Developer

The document provides instructions for creating database tables, inserting data, and defining foreign key constraints for an banking database schema using Oracle SQL Developer. It includes steps to create tables for accounts, transactions, branches, employees, customers and more. Data is then inserted into the department, branch and employee tables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 21

Soal Latihan Prakti Oracle Menggunakan SQL Developer

NIM : 202101068
NAMA : Ahmad Taufik Rahman

#Membuat koneksi
1. Buatlah new connections pada SQL Developer masing-masing, dengan ketentuan:
- Name = studi_kasus_1
- Username = system
- Password = password masing-masing
JAWAB:

#Membuat table
2. Buatlah tabel ACCOUNT
create table ACCOUNT (
ACCOUNT_ID number(10,0) not null,
AVAIL_BALANCE float
CLOSE_DATE date,
LAST_ACTIVITY_DATE date,
OPEN_DATE date not null,
PENDING_BALANCE float,
STATUS varchar2(10 char),
CUST_ID number(10,0),
OPEN_BRANCH_ID number(10,0) not null,
OPEN_EMP_ID number(10,0) not null,
PRODUCT_CD varchar2(10 char) not null,
primary key (ACCOUNT_ID)
);
JAWAB:
3. Buatlah table ACC_TRANSACTION
create table ACC_TRANSACTION (
TXN_ID number(19,0) not null,
AMOUNT float not null,
FUNDS_AVAIL_DATE timestamp not null,
TXN_DATE timestamp not null,
TXN_TYPE_CD varchar2(10 char)
ACCOUNT_ID number(10,0),
EXECUTION_BRANCH_ID number(10,0),
TELLER_EMP_ID number(10,0),
primary key (TXN_ID)
);
JAWAB:

4. Buatlah table BRANCH


create table BRANCH (
BRANCH_ID number(10,0) not null,
ADDRESS varchar230 char),
CITY varchar2(20 char),
NAME varchar2(20 char) not null,
STATE varchar2(10 char),
ZIP_CODE varchar2(12 char),
primary key (BRANCH_ID)
);
JAWAB:

5. Buatlah table BUSINESS


create table BUSINESS (
INCORP_DATE date,
NAME varchar2255 char) not null,
STATE_ID varchar2(10 char) not null,
CUST_ID number(10,0) not null,
primary key (CUST_ID)
);
JAWAB:
6. Buatlah table CUSTOMER
create table CUSTOMER (
CUST_ID number(10,0) not null,
ADDRESS varchar2(30 char),
CITY varchar2(20 char),
CUST_TYPE_CD varchar2(1 char) not null,
FED_ID varchar2(12 char) not null,
POSTAL_CODE varchar2(10 char),
STATE varchar2(20 char)
primary key (CUST_ID)
);
JAWAB:
7. Buatlah table DEPARTMENT
create table DEPARTMENT (
DEPT_ID number(10,0) not null,
NAME varchar2(20 char) not null,
primary key (DEPT_ID)
)
JAWAB:
8. Buatlah table EMPLOYEE
create table EMPLOYEE (
EMP_ID number(10,0) not null,
END_DATE date,
FIRST_NAME varchar2(20 char) not null,
LAST_NAME varchar2(20 char) not null,
START_DATE date not null,
TITLE varchar2(20 char)
ASSIGNED_BRANCH_ID number(10,0),
DEPT_ID number(10,0),
SUPERIOR_EMP_ID number(10,0),
primary key (EMP_ID)
);
JAWAB:

9. Buatlah table INDIVIDUAL


create table INDIVIDUAL (
BIRTH_DATE date
FIRST_NAME varchar2(30 char) not null,
LAST_NAME varchar2(30 char) not null,
CUST_ID number(10,0) not null,
primary key (CUST_ID)
);
JAWAB:
10. Buatlah table OFFICER
create table OFFICER (
OFFICER_ID number(10,0) not null,
END_DATE date,
FIRST_NAME varchar2(30 char) not null,
LAST_NAME varchar2(30 char) not null,
START_DATE date not null
TITLE varchar2(20 char),
CUST_ID number(10,0),
primary key (OFFICER_ID)
);
JAWAB:
11. Buatlah table PRODUCT
create table PRODUCT (
PRODUCT_CD varchar2(10 char) not null,
DATE_OFFERED date
DATE_RETIRED date,
NAME varchar2(50 char) not null,
PRODUCT_TYPE_CD varchar2(255 char),
primary key (PRODUCT_CD)
);
JAWAB:
12. Buatlah table PRODUCT_TYPE
create table PRODUCT_TYPE (
PRODUCT_TYPE_CD varchar2(255 char) not null,
NAME varchar2(50 char),
primary key (PRODUCT_TYPE_CD
);
JAWAB:
#Alter Table
13. alter table ACCOUNT
add constraint ACCOUNT_CUSTOMER_FK
foreign key (CUST_ID)
references CUSTOMER
JAWAB:

14. alter table ACCOUNT


add constraint ACCOUNT_BRANCH_FK
foreign key (OPEN_BRANCH_ID
references BRANCH;
JAWAB:
15. alter table ACCOUNT
add constraint ACCOUNT_EMPLOYEE_FK
foreign key (OPEN_EMP_ID
references EMPLOYEE;
JAWAB:

16. alter table ACCOUNT


add constraint ACCOUNT_PRODUCT_FK
foreign key (PRODUCT_CD
references PRODUCT;
JAWAB
17. alter table ACC_TRANSACTION
add constraint ACC_TRANSACTION_ACCOUNT_FK
foreign key (ACCOUNT_ID
references ACCOUNT;
JAWAB:

18. alter table ACC_TRANSACTION


add constraint ACC_TRANSACTION_BRANCH_FK
foreign key (EXECUTION_BRANCH_ID
references BRANCH;
JAWAB:
19. alter table ACC_TRANSACTION
add constraint ACC_TRANSACTION_EMPLOYEE_FK
foreign key (TELLER_EMP_ID
references EMPLOYEE;
JAWAB:

20. alter table BUSINESS


add constraint BUSINESS_EMPLOYEE_FK
foreignkey (CUST_ID)
references CUSTOMER;
JAWAB:
21. alter table EMPLOYEE
add constraint EMPLOYEE_BRANCH_FK
foreign key (ASSIGNED_BRANCH_ID)
references BRANCH;
JAWAB:

22. alter table EMPLOYE


add constraint EMPLOYEE_DEPARTMENT_FK
foreign key (DEPT_ID)
references DEPARTMENT;
JAWAB:
23. alter table EMPLOYEE
add constraint EMPOYEE_EMPLOYEE_FK
foreign key (SUPERIOR_EMP_ID)
references EMPLOYEE;
JAWAB:

24. alter table INDIVIDUAL


add constraint INDIVIDUAL_CUSTOMER_FK
foreign key (CUST_I)
references CUSTOMER;
JAWAB :
25. alter table OFFICER
26. add constraint OFFICER_CUSTOMER_FK
foreign key (CUST_D)
references CUSTOMER;
JAWAB:

27. alter table PRODUCT


add constraint PRODUCT_PRODUCT_TYPE_FK
foreign key (PRODUT_TYPE_CD)
references PRODUCT_TYPE;
JAWAB:
#Insert Data pada Table
28. Lakukan insert data pada table Department
-- department data
---------------------
insert int department (dept_id, name)
values (1, 'Operations');
---------------------
insert into department (dept_id, name)
values (, 'Loans');
---------------------
insert into department (dept_id, name)
values (3, 'Administration);

insert into department (dept_id, name)


values (4, IT');
JAWAB:
29. Lakukan insert data pada table Branch
insert int branch (branch_id, name, address, city, state, Zip_Code)
values (1, 'Headquarters', '3882 Main St.', 'Waltham', 'MA', '02451');
---------------------
insrt into branch (branch_id, name, address, city, state, Zip_Code)
values (2, 'Woburn Branch', '422 Maple St.', 'Woburn', 'MA', '01801');
---------------------
insert into branch (branch_id, name, address, city, state, Zip_Code)
valus (3, 'Quincy Branch', '125 Presidential Way', 'Quincy', 'MA', '02169');
---------------------
insert ito branch (branch_id, name, address, city, state, Zip_Code)
values (4, 'So. NH Branch', '378 Maynard Ln.', 'Salem', 'NH', '03079');
JAWAB:

30. Lakukan insert data pada table employee


insert ino employee (emp_id, First_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (1, 'Michael', 'Smith', to_date('2001-06-22','yyyy-MM-dd'),
(select dept_id from department where name = 'Administration'),
'President',
(select branch_id from branch where name = 'Headquarters'));
---------------------
isert into employee (emp_id, First_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (, 'Susan', 'Barker',to_date( '2002-09-12','yyyy-MM-dd'),
(select dept_id from department where name = 'Administration'),
'Vice President',
(select branch_id from branch where name = 'Headquarters'));
---------------------
insert into eployee (emp_id, First_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (3, 'Robert', 'Tyler',to_date( '2000-02-09','yyyy-MM-dd'),
(select dept_id from department where name = 'Administration'),
'Treasurer',
(select branch_id from branch where name = 'Headquarters'));
---------------------
insert nto employee (emp_id, First_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (4, 'Susan', 'Hawthorne',to_date( '2002-04-24','yyyy-MM-dd'),
(select dept_id from department where name = 'Operations'),
'Operations Manager',
(select branch_id from branch where name = 'Headquarters'));
---------------------
insert into employe (emp_id, First_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (5, 'John', 'Gooding',to_date( '2003-11-14','yyyy-MM-dd'),
(select dept_id from department where name = 'Loans'),
'Loan Manager',
(select branch_id from branch where name = 'Headquarters'));
---------------------
insert into eployee (emp_id, First_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (6, 'Helen', 'Fleming',to_date( '2004-03-17','yyyy-MM-dd'),
(select dept_id from department where name = 'Operations'),
'Head Teller',
(select branch_id from branch where name = 'Headquarters'));
---------------------
insert into employee (mp_id, First_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (7, 'Chris', 'Tucker',to_date( '2004-09-15','yyyy-MM-dd'),
(select dept_id from department where name = 'Operations'),
'Teller',
(select branch_id from branch where name = 'Headquarters'));
---------------------
insert into employee (emp_id, Frst_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (8, 'Sarah', 'Parker',to_date( '2002-12-02','yyyy-MM-dd'),
(select dept_id from department where name = 'Operations'),
'Teller',
(select branch_id from branch where name = 'Headquarters'));
---------------------
insert into employee (emp_id, Firt_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (9, 'Jane', 'Grossman',to_date( '2002-05-03','yyyy-MM-dd'),
(select dept_id from department where name = 'Operations'),
'Teller',
(select branch_id from branch where name = 'Headquarters'));
---------------------
insert into employee (emp_id, Fist_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (10, 'Paula', 'Roberts',to_date( '2002-07-27','yyyy-MM-dd'),
(select dept_id from department where name = 'Operations'),
'Head Teller',
(select branch_id from branch where name = 'Woburn Branch'));
---------------------
insert into employee (emp_id, irst_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (11, 'Thomas', 'Ziegler',to_date( '2000-10-23','yyyy-MM-dd'),
(select dept_id from department where name = 'Operations'),
'Teller',
(select branch_id from branch where name = 'Woburn Branch'));
---------------------
insert into employee (emp_id, First_Name, Last_Name, start_date,
dep_id, title, assigned_branch_id)
values (12, 'Samantha', 'Jameson',to_date( '2003-01-08','yyyy-MM-dd'),
(select dept_id from department where name = 'Operations'),
'Teller',
(select branch_id from branch where name = 'Woburn Branch'));
---------------------
insert into employee (emp_id, First_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (13, 'John', 'Blake',to_date( '2000-05-11','yyyy-MM-dd'),
(select dept_id from dpartment where name = 'Operations'),
'Head Teller',
(select branch_id from branch where name = 'Quincy Branch'));
---------------------
insert into employee (emp_id, First_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (14, 'Cindy', 'Mason',to_date( '2002-08-09','yyyy-MM-dd'),
(select dept_id from deparment where name = 'Operations'),
'Teller',
(select branch_id from branch where name = 'Quincy Branch'));
---------------------
insert into employee (emp_id, First_Name, ast_Name, start_date,
dept_id, title, assigned_branch_id)
values (15, 'Frank', 'Portman',to_date( '2003-04-01','yyyy-MM-dd'),
(select dept_id from department where name = 'Operations'),
'Teller',
(select branch_id from branch where name = 'Quincy Branch'));
---------------------
insert into employee (emp_id, First_Name, Last_Nme, start_date,
dept_id, title, assigned_branch_id)
values (16, 'Theresa', 'Markham',to_date( '2001-03-15','yyyy-MM-dd'),
(select dept_id from department where name = 'Operations'),
'Head Teller',
(select branch_id from branch where name = 'So. NH Branch'));
---------------------
insert ino employee (emp_id, First_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (17, 'Beth', 'Fowler',to_date( '2002-06-29','yyyy-MM-dd'),
(select dept_id from department where name = 'Operations'),
'Teller',
(select branch_id from branch where name = 'So. NH Branch'));
---------------------
insert into eployee (emp_id, First_Name, Last_Name, start_date,
dept_id, title, assigned_branch_id)
values (18, 'Rick', 'Tulman',to_date( '2002-12-12','yyyy-MM-dd'),
(select dept_id from department where name = 'Operations'),
'Teller',
(select branch_id from branch where name = 'So. NH Branch'));

JAWAB:

You might also like