CIS4365: Database Applications
Fall, 2017

Creating the Database

Return to Home Page

Get into the Oracle SQL System. When you see the prompt:

SQL>

You know you are ready to go. There are a few ways to execute the commands in your file. The easiest is to enter the command:

SQL> @medical.sql;

OR:

SQL> start medical.sql;

Don't forget the semicolon(;)! These commands (@ and START -- @ is the shortcut for the command START) tell the system to go get the file called medical.sql, open it, and execute the commands contained in it. If you stored you created in a subdirectory (e.g., C:\Myfiles\SQL) you will have to enter the command:

SQL> @C:\Myfiles\SQL\medical.sql;

Having said all that, I strongly recommend that you do NOT use that command. You are just getting started, you will make mistakes, and if you try and execute all of the files at once, it could get too confusing. Instead, I recommend you take the commands you entered in your file, and execute each command individually using cut-and-paste. For example, your file probably contains the command (NOTE that this is a SINGLE command since it has only one semicolon - at the end of the command):

I suggest you now highlight that command:


 

Use your ^C (Control C) command to copy it, go back to the SQL Prompt, and use your ^V (Control V) command to paste it in:

SQL> CREATE TABLE physician
SQL>( CHAR(9),
SQL>physname CHAR(30) NOT NULL,
SQL>specialty CHAR(15) NOT NULL,
SQL>street CHAR(20),
SQL>city CHAR(20) DEFAULT 'Arlington',
SQL>state CHAR(2) DEFAULT 'TX',
SQL>zip CHAR(5),
SQL>PRIMARY KEY (physid),
SQL>FOREIGN KEY (supervisor) REFERENCES physician (physid),
SQL>UNIQUE (specialty) );
 

If everything goes well, you will know that command is OK. If you get an error message, you will know where the error occurred. If you do have an error, CORRECT IT IN THE COMMAND FILE (Not directly in the SQL environment).

Repeat the process for the entire script.

If you run into any problems, I will be glad to help you. Either ask me in the Lab, in the classroom, or see me outside of class

 

  This page was last updated on 08/24/03.