Please send questions to st10@humboldt.edu .
-- everything after two dashes is a "classic" SQL (single-line) comment

/* Hey! Oracle SQL (at least) also supports C++-style multi-line
   comments -- everything between slash-star and star-slash is ignored
*/

/* it matters in SQL*Plus how you END a SQL command;
   in SQL*plus, a SQL command must be terminated by a semicolon
      to indicate that you're ready to run it;

      no semicolon? the SQL statement will simply be ignored!

      (and you don't use the semicolon when embedding SQL
      within Java, PHP, etc.)

      *   a SQL command can be on multiple lines, but should
          NOT have blank lines WITHIN a single SQL statement;

   SQL*Plus commands are one-line commands, and no semicolon
   is needed (but nothing bad happens if you put one)
*/

/* SQL*Plus command: spool

   spool filename.txt  <--- course style standard: end spool files in .txt

   ...

   spool off

   the first command starts spooling -- everything that shows on
      screen goes into that file --
   and the second flushes any un-copied-over output and stops the
      spooling;
*/

spool 315lab02-out.txt

select 3 * 4
from dual;

/* note: @ is a "shorthand" for the SQL*Plus start command you can
   use to run a SQL script */
   /* and it is OK to omit the .sql from the script file name
      in the start command */

/* these ALL attempt to run the SQL script (in the current working
   directory) named myscript.sql
start myscript.sql
@ myscript.sql
start myscript
@ myscript
*/

-- we often precede a create-table statement with a drop table statement:

drop table parts;

-- example of a create table statement:

create table parts
(part_num          integer, 
 part_name         varchar2(25),
 quantity_on_hand  smallint,
 price             decimal(6, 2),
 level_code        char(3),
 last_inspected    date,
 primary key       (part_num)
);

-- SQL*Plus describe command describes a table's structure

describe parts

-- SQL command insert lets me insert a row into a table

-- use SINGLE QUOTES to write a string literal!!!!

insert into parts
values
(10603, 'hexagonal wrench', 13, 9.99, '003', '05-sep-2000');

insert into parts(part_num)
values
(10604);

-- to see a table's contents, here is the SIMPLEST version
--    of the SQL select statement

select *
from   parts;

spool off