Re: few questions from a beginner

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 1996/06/08
Message-ID: <31b9d0a3.12788649_at_dcsun4>#1/1


On Fri, 07 Jun 1996 13:15:54 -0700, alpa sandesara <alpa.sandesara_at_tempe.asu.edu> wrote:

>I have just started playing around oracle7. I have a few questions about
>SQL Plus.
>1. What is the datatype which can act as a counter, or a serial number,
>which can act as primary key in creating a table?

the datatype is number, the database object is called a sequence. for example:

create table foo ( x int primary key, .... );

create sequence foo_seq;

create triggr foo_bifer
before insert on foo
for each row
begin

   select foo_seq.nextval into :new.x from dual; end;
/

Would do it.

>2. If I want to type the whole query in text editor in simple text file,
>how I can run that query in SQL Plus?

The easiest way is to save the file as filename.SQL. then in sql*plus you can SQL> _at_filename

If you do not choose to use .sql as the file type then you would: SQL> _at_filename.type

If you choose not you use an extension at all then you are out of luck :) plus will add the .sql extension and then not be able to find the file.

>3. I just wrote simple statement
> 'create database tmp;'
> It gives me error ' insufficient priviledgs '
>

I assume you are an Informix user (since you referenced serial types above). Oracle does not do a 'database' in the way Informix does. I don't think you want to create a database (that would involve creating a whole instance with its own SGA, set of processes, configuration files, etc.). In Oracle you will use a schema (owner) in the way you used databases in Informix.

A schema is a database account, for example, you probably have a "scott" schema. To retrieve stuff from scotts schema you would issue "select * from scott.emp".

>Is there somebody who can really answer my tiny questions? I really do
>not know unix much. I want to do this query in SQL Plus for oracle7 on
>Solaris.
>
>********************************************************************
>
> ALPA SANDESARA
>
> EMail : alpa.sandesara_at_tempe.vlsi.com
> alpa.sandesara_at_asu.edu
> Phone : (602) 752 - 6342
>
> " I LOVE INDIA "
>
>********************************************************************
>

Thomas Kyte
Oracle Government
tkyte_at_us.oracle.com                          

http://govt.us.oracle.com -- Check out our web site! Brand new, uses Oracle Web Server and Database


statements and opinions are mine and do not necessarily reflect the opinions of Oracle Corporation Received on Sat Jun 08 1996 - 00:00:00 CEST

Original text of this message