(CIS 326) Working with iSQL*Plus 1. Connect to the Internet, and start the web browser. 2. Enter the URL http://gl381-oracle.missouristate.edu:5560/isqlplus in the Web browser's Location or Address area. The iSQL*Plus Login screen is displayed in the web browser. 3. Enter your Oracle 10g username and password in the Username text box and Password text box. Leave the Connection Identifier text box blank to connect to the default database. Click Login to connect to the database. 4. The iSQL*Plus Work screen (as shown below) is displayed in your web browser. 5. Now start entering and executing SQL, PL/SQL and SQL*Plus statements and commands in the Work screen area. 1 iSQL*Plus WORK SCREEN USER INTERFACE DESCRIPTION File or URL: Enter the path and filename (or the URL) of the script file you want to load into the work area for editing or execution. Browse: Click the Browse button to search for a script file that you want to load for editing or execution. When you select the file, its path and name are entered in the File or URL text box. Load Script: Click the Load Script button to load the script specified in the File or URL text box into the iSQL*Plus work area for editing or execution. Enter statements: Enter SQL statements, PL/SQL blocks, or iSQL*Plus commands. This area is also referred to as the work area. You can resize the Input area in the Interface Options screen which you access from the Preferences screen. Execute: Click the Execute button to execute the contents of the work area. Depending on your preference settings, the results are displayed in the Work screen, in a new web browser window, or saved to a file. Use the Web Browser Print button/option to print the results. Save Script: Click the Save Script button to save the contents of the work area to a file. You are prompted to enter the name of the file. The file extension you choose is for your convenience. It may be convenient to identify scripts with an extension of .SQL. Clear Screen: Click the Clear Screen button to clear all statements in the work area, and all displayed output. Cancel: Click the Cancel button to interrupt the script that is currently running. 2 Oracle Names & Data Types All Oracle object names like table name, attribute name, index name, constraint name, etc should follow the following convention. Naming Standard Invalid Names Example Spaces not allowed in between words. Customer Order Hyphens not allowed between words. Customer-Order Must begin with a letter 9Customer Cannot exceed 30 characters employee_social_security_numbers_column Some of the commonly used data types supported by Oracle are shown below. Data Type Description CHAR(n) Fixed length character of length n. Maximum 2000 characters. VARCHAR2(n) Variable length character up to length n. Maximum 4000 characters. NUMBER(n) Numeric value of length n. NUMBER(n,d) Numeric value of length n, with d places right of the decimal. NUMBER Floating point numeric value. DATE Date value containing both date and time. INT Whole number of length 38. Constraints There are two types of constraints in Oracle – integrity constraint and value constraint. Integrity constraints are associated with primary key and foreign key specification. Value constraints are associated with limitations on attribute values like range, default, not null and so on. Constraints are defined during the table definition. The general syntax of constraint is: CONSTRAINT <constraint name> <specification details> All constraint names must be unique in the database. 3 SQL Statements to Create & Populate Database Consider a small schema consisting of three tables (primary keys are underlined, foreign keys are in italics): STUDENT(SID, Name, Major, GPA, DOB, Age, Status) ENROLLMENT(SID,Class_Name,Position) CLASS(Name,Room,Time) The SQL statements to create the schema is as follows: create table student (sid number(3) constraint student_pk primary key, name varchar2(25), major varchar2(10), gpa number(3,2), dob date, age number(2), status char(2)); create table class (name varchar2(10) constraint class_pk primary key, room varchar2(10), time varchar2(10)); create table enrollment (sid number(3), class_name varchar2(10) constraint enrollment_fk1 references class, position number(1), constraint enrollment_pk primary key (sid,class_name), constraint enrollment_fk2 foreign key (sid) references student); A sample SQL statement to insert a row in Student table is as follows: insert into student values (100,'Tanya','History',3.45,to_date('12/7/80','mm/dd/yy'),23,'JR'); Script Files A text file containing one or more SQL statements. Each statement ends with a semi-colon (;). An example script file can be created by entering the above SQL statements in a text file. Script files have to be loaded into iSQL*Plus for execution. Script files are useful for documentation purposes. 4