Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Lab # 1 Introduction to Oracle Eng. Haneen El-Masry October, 2014
2 Objective To be familiar with Oracle DataBase Management System. What is a DataBase? A database is a collection of related data that is known facts that can be recorded and that have implicit meaning. Examples: University, Library, ect. A database may be generated and maintained manually or it may be computerized. A computerized database may be created and maintained by a database management system (DBMS). What is the DBMS? DBMS is a collection of programs that enables users to create and maintain a database. DBMS is a general-purpose software system that facilitates the processes of defining, constructing, manipulating, and sharing databases among various users and applications. DBMS includes protecting the database and maintaining it over a long period of time. DBMS Responsibilities Creating the database. Providing query and update facilities. Multitasking. Managing the security of the database. Maintaining referential integrity. Examples: Oracle, SQL Server, MySQL, PostgreSQL. For our lab, we will use Oracle Database Express Edition 11.2g.
3 DataBase System The database and DBMS software together are called a database system. Figure 1: DataBase System Oracle DataBase Oracle Database (commonly referred to as Oracle RDBMS or simply as Oracle) is an object-relational database management system produced and marketed by Oracle Corporation. Its last version is Oracle 12c (c refers to cloud) and its primary query language is PL/SQL.
4 Oracle XE Installation on Windows 1- Double click on setup.exe 2- Next.
5 3- Accept the license Agreement >> Next. 4- Next.
6 5- Enter the password for SYS and SYSTEM default users that will be explained later in this lab. manager ^_^ 6- Install.
7
8 7- Finish. ^_^
9 Oracle XE Default Users/Schemas During installation, Oracle XE create a default database called XE. XE database contains many schemas that each of them has an owner with the same name. Schemas Schemas are the most important objects within the database. A schema is a collection of database objects. A schema is owned by a database user and has the same name as that user. Schema objects include structures like tables, triggers, functions, views, and other objects for handling data in the database. The Schemas have two purposes: To help manage the access of many different users to a single database. To allow extra tables to be associated with a standard database, but kept separate. User Name SYS SYSTEM HR Description All of the base tables and views for the database's data dictionary are stored in the schema SYS. These base tables and views are critical for the operation of Oracle. To maintain the integrity of the data dictionary, tables in the SYS schema are manipulated only by Oracle; they should never be modified by any user or database administrator, and no one should create any tables in the schema of the user SYS. The account password is set upon installation. The SYSTEM username creates additional tables and views that display administrative information, and internal tables and views used by Oracle tools. Never create in the SYSTEM schema tables of interest to individual users. SYSTEM is a little bit "weaker" user than SYS, for example, it has no access to the very internal structure tables of Oracle. The account default password is manager and it is changed upon installation. Oracle Database XE comes with a sample database user called HR. This user owns a number of database tables in a sample schema that can be used to create applications for a fictional Human Resources department. However, for security reasons, this user's account is locked, and we need to unlock it.
10 SQL Command Line SQL*Plus It is an interactive command-line query tool that is installed with Oracle Database Express Edition. HR Unlock To unlock HR user, you need to do two steps: 1- Connect to the XE database. We will connect using SYSTEM account that has administrative privileges. 2- Unlock HR user. DataBase Connection To connect to any database, you need to determine the following five parameters: Host or host address: is the host name or IP address of the computer that is running Oracle Database XE. If not specified, the default host is localhost. Port: is the TCP port number on which the Oracle Net listener is listening. If not specified, the default port number 1521 is assumed. Database name: is the name of the database service to which to connect. If service_name is omitted, Oracle Database XE Client appends a request for the default database service, which is configured during installation as XE. User name. Password.
11 Connect to DatBase connect username/password@host:port/service_name Unlock database account alter user username identified by password account unlock; Retrieving Tables Names in a Schema SELECT TABLE_NAME FROM USER_TABLES;
12 Oracle SQL Developer Oracle SQL Developer is the Oracle Database IDE. A free graphical user interface, Oracle SQL Developer allows database users and administrators to do their database tasks in fewer clicks and keystrokes. 1- Double click on sqldeveloper. 2- Specify the path to Java JDK.
13 3- No.
14 Start Page ^_^.
15 Connect to XE database by HR user 1- Click on Connections then click on icon. 2- Enter Connection Parameters.
16 3- Test. Success ^_^ 4- Connect.
17 Query Example ^_^ Best Wishes