Download presentation
Presentation is loading. Please wait.
Published byGyles Hodge Modified over 9 years ago
1
Managing Database With Oracle Replacement for Ch10 COP 4708
2
Introduction Oracle is the world’s most popular DBMS - It is a powerful and robust DBMS that runs on many different operating systems Oracle DBMS engine available in several versions:versions –The Personal Edition of Oracle (is available with this text and can also be downloaded from Oracle) –Express Edition (the one that we downloaded and installed) –Standard Edition –Professional Edition Example of Oracle products: –SQL*Plus: a utility for processing SQL and creating components like stored procedures and triggers: PL/SQL is a programming language that adds programming constructs to the SQL language –Oracle Developer (Forms & Reports Builder)
3
Starting With Oracle Click on Application Express to start working with Oracle
4
Starting with Oracle You will get a login screen where you enter your username (sys) and password (whatever the password that you used during installing Oracle)
5
Create User or Use Existing Once you login you can create a new user workspace or use existing workspace
6
Oracle User Interface
7
Creating Tables Click on SQL Workshop, Object Browser, and from the Create Object Menu select Table
8
Creating Table Once you click on the create table tab you will get this screen Fill in the name of the table as ARTIST from the View Ridge Gallery Database Fill in the different columns needed as indicated in the following slide
9
ARTIST Table Column NameColumn TypeSizeNULL ArtsitIDNumber(38,1)No NameChar25No NationalityVarchar230Yes BirthDateNumber(4,0)Yes DeceasedDateNumber(4,0)Yes
10
ARTIST Table Once you insert the column name, type size and the null constraint click next to choose a primary key for the table
11
Primary Key Select Not Populated since you will entering the values your self. Then select the primary key to be ArtistID and click Next twice to skip Foreign Key setup to constraints
12
Adding Constraint You can choose the type of constraint whether Check or Unique The name of the constraint will be created Automatically
13
Adding Constraints Check Constraints: –(Nationality In ('Canadian', 'English', 'French', 'German', 'Mexican', 'Russian', 'Spanish', 'US')) –(BirthDate < DeceasedDate) –(Birthdate > 1000) and (Birthdate < 2100) –(DeceasedDate > 1000) and (DeceasedDate < 2100) Unique Constraint: –Name
14
Adding Constraints This is a snapshot of all the constraints that have been added. You will have 4 check and one unique Click Finish then confirm the table creation by clicking on Create
15
Table Manipulation The table has been created You can Drop (Delete) the table by clicking on Drop, or You can rename the table by clicking on Rename You can Add a new column You can modify an existing column You can rename a column You can drop a column
16
Table Manipulation Exercise Add a column called MyColumn with a data type char (20) Rename that column to ArtistAge Modify the data type to be Number (5,0) Drop that column
17
Inserting Data Into Table To insert data into table click on the Data tab then click Insert Row
18
ArtistIDNameNationalityBirthDateDeceasedDate 3MiroSpanish18701950 4KandinskyRussian18541900 5FringsUS1950Null 6KleeGerman1900Null 8MoosUSNull 14TobeyUSNull 15MattFrenchNull 16ChagallFrenchNull Insert Data into table then click Create and Create Another Use the information provided here After the last entry click Create tab
19
Table Including Data You should be able to have the table with all data inserted as shown in the figure You can count the number of rows in the table or you can insert more records (rows of data) Click on SQL
20
SQL Code For Artist Table CREATE TABLE "ARTIST" ( "ARTISTID" NUMBER(38,1) NOT NULL, "NAME" CHAR(25) NOT NULL, "NATIONALITY" VARCHAR2(30), "BIRTHDATE" NUMBER(4,0), "DECEASEDDATE" NUMBER(4,0), CONSTRAINT "ARTIST_PK" PRIMARY KEY ("ARTISTID"), CONSTRAINT "ARTIST_CK1" CHECK ((Nationality In ('Canadian', 'English', 'French', 'German', 'Mexican', 'Russian', 'Spanish', 'US')), CONSTRAINT "ARTIST_CK2" CHECK ((BirthDate < DeceasedDate)), CONSTRAINT "ARTIST_CK3" CHECK ((Birthdate > 1000) and (Birthdate < 2100)), CONSTRAINT "ARTIST_CK4" CHECK ((DeceasedDate > 1000) and (DeceasedDate < 2100) ), CONSTRAINT "ARTIST_UK1" UNIQUE ("NAME") ) This is the automated code that has been created by the system
21
Exercise Create WORK table using the following Information Column NameColumn TypeSizeNULL WorkIDNumber(38,1)No TitleVarchar225No DescriptionVarchar21000Yes CopyVarchar28Yes ArtistIDNumberNo
22
Exercise (Cont.) Assign a primary key Assign a foreign key remember to add the reference table as ARTIST and the reference column Add the following constraints: –Title, copy as unique
23
Exercise (Cont.) Then insert the following information: WorkIDTitleDescriptionCopyArtistID 505Mystic FabricOpposite meaning99/13514 506Mi VidaDark background7/1003 507Slow EmbersFrom the artist’s originalsHC14 525Mystic FabricSome water damage105/13514 530Northwest By NightWonderful, moody37/5016
24
Work Table Created with Data You should be able to get the table shown in the figure with populated rows Click on Model
25
Database Model Oracle screen that shows the conceptual model of the database and the relation between the ARTIST table and the WORK table
26
Table Dependencies When you click on Dependencies the system will list the tables that the WORK table depends on Now click on Create to create a View
27
Creating View In the view name enter ArtistNameView Then write the SQL code to create the view in the query box
28
Viewing and Manipulating the View The view will be created To look at the view or the query that you created click on Data and you will see this table with artists’ names CREATE OR REPLACE FORCE VIEW "ARTISTNAMEVIEW" "ARTISTNAME") AS Select Name as ArtistName From ARTIST When click on SQL you will get the code for creating the view including the query You can click on Drop to delete the view
29
Utilities So we used the Administration tab, the object browser tab, the SQL tab, how about utilities? Click on utilities then select Data Load/Unload then select load
30
Utilities Select Load Spreadsheet Data and you will get this screen Select New Table Select Upload File
31
Spreadsheet file Before you upload the file to Oracle open your Excel sheet that has the table Click save as Keep the file under the same name in our case will be (Customer Table) Select Save as type (Text (Tab delimited)(*.text) then save
32
Uploading Data from Spreadsheet Browse to the txt file that you just saved then set separator \t for tab Click Next
33
Creating Table In The Database Name the table as CUSTOMER All columns been loaded and data type been recognized
34
Creating Customer Table To setup the primary key select use an existing column and choose Customer_ID Then select Not generated Then Click Load Data
35
Creating Customer Table Table has been imported To make sure of that go to the home page click Object Browser, browse for tables, you will see the customer table been created and if you click on Data you will see the table populated with data
36
Customer Table with Populated Rows
37
Generating Object Reports Also under Utilities tab you can generate Object Reports that provides different reports about the objects included in the database, such as a report about the different columns, their type and their size
38
Restoring Deleted Objects Also You can retrieve or restore object that has been deleted by mistake by going to the Recycle Bin and choosing Dropped Objects Then select from the list the object that you would like to restore
39
Click on Restore Object Restoring Deleted Objects
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.