b_bookg.gif (182 bytes)Guides (Oracle8p)

Case Study: Heights

H-6a

SQL*Plus: Table

1. By entering commands into the buffer (Refer to Buffer & working commands)
create table Heights
  ( FullName varchar2 (30) ,
    Height number,
    constraint pkFullName primary key(FullName)
  );
  • Creating a heights table
    • Next to SQL type Input (or I)
    • Enter the SQL shown left
    • Enter a / (or R) to run the buffer SQL.
    • This should create the table
    • Enter CL BUFF to empty the buffer
desc Heights;
  • Display the height table structure
    • Enter the SQL shown left
    • Run the SQL then clear the buffer
insert into Heights
(FullName, Height) values ('Chrys Lyon', 122);
insert into Heights
(FullName, Height) values ('Ellee Fant', 192);
  • Insert data into the table
    • Enter the SQL shown left
    • Run the SQL then clear the buffer
  • Note: Column names recommended for Insert as table may change in future.
SELECT * FROM Heights;
  • Display data in the table
    • Enter the SQL shown left
    • Run the SQL then clear the buffer
2. Creating a batch file  
REM use START <filename> in SQL*Plus to run this batch file
DROP TABLE Heights;
create table Heights
( FullName varchar2 (30) ,
  Height number,
  constraint pkFullName primary key(FullName)
);
desc Heights;
-- Column names recommended for Insert as table may change in future.
-- You can use two dashes instead of REM
insert into Heights
  (FullName, Height) values ('Chrys Lyon', 122);
insert into Heights
  (FullName, Height) values ('Ellee Fant', 192);

select * from Heights
  • You can batch process SQL*Plus by creating afile in the default editor (Windows 95 is Notepad)
  • Enter: ED H:/Oracle/heights/one.sql
    • Enter the SQL commands as shown (left)
    • Exit notepad
    • Enter: START H:/Oracle/heights/one.sql
      the following script output will be generated;
      dbh_sq2.gif (5788 bytes)
  • Question: How does the DROP command work?

[Rev 14/05/99] 25/3/98 © 1999 V/2-Com (Verhaart), P O Box 8415, Havelock North, New Zealand.