Upload
philip-wiggins
View
220
Download
1
Embed Size (px)
Citation preview
Data Definition Language
Using sqldeveloper
To create connection
• Create new connection (any name)• Username: sys• Password: oracle11• Tick on Save password• Connection type: Basic; Role: SysDBA • Hostname: localhost • Port:1521 • SID: xe • Click on Test button • When status is successful; click on connect button
Create user
1. Look for Other user in your connection2. Right click on other user3. Click create user
1. User name: yourname (do not put any space)2. Password: (anything)3. New password:
4. Click on Roles tab – grant all, admin all, default all5. Click on system privileges – grant all, admin all6. Click on Apply button7. Click on Close button
Create table
create table yourname.dept(ID number(7),Dname varchar2(25));
** check table yourname.dept created ****
To confirm the table exists
DESCRIBE yourname.dept
Populate the table
• insert into yourname.deptvalues (101, 'Info Sys');
• insert into yourname.deptvalues (102, 'Marketing');
• insert into yourname.deptvalues (103, ‘Finance');
Create another table
create table yourname.department(deptID number(7),Deptname varchar2(25));
** check table yourname.department created *
Insert the following record in Department table
deptID Deptname
100 Human Resource
120 Network
130 Retail
Copy data from Department into Dept
insert into yourname.deptselect deptID, deptname from yourname.department;
Create new table (copydept) and populate using data from dept table
create table yourname.copydeptas select id, dname from yourname.dept;
Do exercise 1 from metalab