<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.zcubes.com/index.php?action=history&amp;feed=atom&amp;title=Yurttas%2FPL%2FDBL%2Foracle%2FF%2FR%2For-intro.html</id>
	<title>Yurttas/PL/DBL/oracle/F/R/or-intro.html - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.zcubes.com/index.php?action=history&amp;feed=atom&amp;title=Yurttas%2FPL%2FDBL%2Foracle%2FF%2FR%2For-intro.html"/>
	<link rel="alternate" type="text/html" href="http://wiki.zcubes.com/index.php?title=Yurttas/PL/DBL/oracle/F/R/or-intro.html&amp;action=history"/>
	<updated>2026-04-28T03:17:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.2</generator>
	<entry>
		<id>http://wiki.zcubes.com/index.php?title=Yurttas/PL/DBL/oracle/F/R/or-intro.html&amp;diff=82544&amp;oldid=prev</id>
		<title>MassBot1: Created page with &quot;=&lt;font size=&quot;+3&quot;&gt;Getting Started With Oracle&lt;/font&gt;   ----=    * Overview  * yurttas/PL/DBL/oracle/F/R/#logging in to oracle|Logging...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.zcubes.com/index.php?title=Yurttas/PL/DBL/oracle/F/R/or-intro.html&amp;diff=82544&amp;oldid=prev"/>
		<updated>2013-11-05T05:35:25Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;=&amp;lt;font size=&amp;quot;+3&amp;quot;&amp;gt;Getting Started With Oracle&amp;lt;/font&amp;gt;   ----=    * &lt;a href=&quot;/index.php?title=Yurttas/PL/DBL/oracle/F/R/&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Yurttas/PL/DBL/oracle/F/R/ (page does not exist)&quot;&gt;Overview&lt;/a&gt;  * yurttas/PL/DBL/oracle/F/R/#logging in to oracle|Logging...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=&amp;lt;font size=&amp;quot;+3&amp;quot;&amp;gt;Getting Started With Oracle&amp;lt;/font&amp;gt;   ----=&lt;br /&gt;
&lt;br /&gt;
* [[yurttas/PL/DBL/oracle/F/R/#overview|Overview]]&lt;br /&gt;
* [[yurttas/PL/DBL/oracle/F/R/#logging in to oracle|Logging In to Oracle]]&lt;br /&gt;
* [[yurttas/PL/DBL/oracle/F/R/#changing your password|Changing Your Password]]&lt;br /&gt;
* [[yurttas/PL/DBL/oracle/F/R/#creating a table|Creating a Table]]&lt;br /&gt;
* [[yurttas/PL/DBL/oracle/F/R/#inserting tuples|Inserting Tuples]]&lt;br /&gt;
* [[yurttas/PL/DBL/oracle/F/R/#getting the value of a relation|Getting the Value of a Relation]]&lt;br /&gt;
* [[yurttas/PL/DBL/oracle/F/R/#getting rid of your tables|Getting Rid of Your Tables]]&lt;br /&gt;
* [[yurttas/PL/DBL/oracle/F/R/#info about db|Getting Information About Your Database]]&lt;br /&gt;
* [[yurttas/PL/DBL/oracle/F/R/#quitting sqlplus|Quitting sqlplus]]&lt;br /&gt;
* [[yurttas/PL/DBL/oracle/F/R/#executing sql from a file|Executing SQL From a File]]&lt;br /&gt;
* [[yurttas/PL/DBL/oracle/F/R/#editing commands in the buffer|Editing Commands in the Buffer]]&lt;br /&gt;
* [[yurttas/PL/DBL/oracle/F/R/#recording your session|Recording Your Session]]&lt;br /&gt;
* [[yurttas/PL/DBL/oracle/F/R/#help facilities and other hints|Help Facilities and Other Hints]]&lt;br /&gt;
&lt;br /&gt;
===---- Overview===&lt;br /&gt;
&lt;br /&gt;
You will be using the Oracle database system to implement your PDA (Personal Database Application) this quarter. '''Important: '''''As soon as your Oracle account is set up, you should log in to change the initial password.''&lt;br /&gt;
&lt;br /&gt;
===---- Logging In to Oracle===&lt;br /&gt;
&lt;br /&gt;
You should be logged onto one of the Sun Solaris machines at L&amp;amp;amp;IR. These machines include elaine, epic, saga, adelbert, tree, and cardinal.&lt;br /&gt;
&lt;br /&gt;
Before using Oracle, execute the following line in your shell to set up the correct environment variables:&lt;br /&gt;
&lt;br /&gt;
      source /usr/class/cs145/cora.env&lt;br /&gt;
&lt;br /&gt;
You may wish to put this line in your shell initialization file instead (for example, &amp;lt;tt&amp;gt;.cshrc&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Now, you can log in to Oracle by typing:&lt;br /&gt;
&lt;br /&gt;
      sqlplus &amp;amp;lt;yourName&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, &amp;lt;tt&amp;gt;sqlplus&amp;lt;/tt&amp;gt; is Oracle's generic SQL interface. &amp;lt;tt&amp;gt;&amp;amp;lt;yourName&amp;amp;gt;&amp;lt;/tt&amp;gt; refers to your leland login.&lt;br /&gt;
&lt;br /&gt;
You will be prompted for your password. This password is initially &amp;lt;tt&amp;gt;dbpasswd&amp;lt;/tt&amp;gt; and ''must'' be changed as soon as possible. For security reasons, we suggest that you ''not'' use your regular leland password, because as we shall see there are opportunities for this password to become visible under certain circumstances. After you enter the correct password, you should receive the prompt&lt;br /&gt;
&lt;br /&gt;
      SQL&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
===---- Changing Your Password===&lt;br /&gt;
&lt;br /&gt;
In response to the &amp;lt;tt&amp;gt;SQL&amp;amp;gt;&amp;lt;/tt&amp;gt; prompt, type&lt;br /&gt;
&lt;br /&gt;
      alter user &amp;amp;lt;yourName&amp;amp;gt; identified by &amp;amp;lt;newPassword&amp;amp;gt;;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;tt&amp;gt;&amp;amp;lt;yourName&amp;amp;gt;&amp;lt;/tt&amp;gt; is again your leland login, and &amp;lt;tt&amp;gt;&amp;amp;lt;newPassword&amp;amp;gt;&amp;lt;/tt&amp;gt; is the password you would like to use in the future. This command, like all other SQL commands, should be terminated with a semicolon.&lt;br /&gt;
&lt;br /&gt;
===---- Creating a Table===&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;tt&amp;gt;sqlplus&amp;lt;/tt&amp;gt; we can execute any SQL command. One simple type of command creates a table (relation). The form is&lt;br /&gt;
&lt;br /&gt;
      CREATE TABLE &amp;amp;lt;tableName&amp;amp;gt; (&lt;br /&gt;
          &amp;amp;lt;list of attributes and their types&amp;amp;gt;&lt;br /&gt;
      );&lt;br /&gt;
&lt;br /&gt;
You may enter text on one line or on several lines. If your command runs over several lines, you will be prompted with line numbers until you type the semicolon that ends any command. ('''Warning''': An empty line terminates the command but does not execute it; see [[yurttas/PL/DBL/oracle/F/R/#editing commands in the buffer|Editing Commands in the Buffer]].) An example table-creation command is:&lt;br /&gt;
&lt;br /&gt;
      create table test (&lt;br /&gt;
          i int,&lt;br /&gt;
          s char(10)&lt;br /&gt;
      );&lt;br /&gt;
&lt;br /&gt;
Note that SQL is ''case insensitive'', so &amp;lt;tt&amp;gt;CREATE TABLE TEST&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;create table test&amp;lt;/tt&amp;gt; are the same. This command creates a table named &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; with two attributes. The first, named &amp;lt;tt&amp;gt;i&amp;lt;/tt&amp;gt;, is an integer, and the second, named &amp;lt;tt&amp;gt;s&amp;lt;/tt&amp;gt;, is a character string of length (up to) 10.&lt;br /&gt;
&lt;br /&gt;
===---- Inserting Tuples===&lt;br /&gt;
&lt;br /&gt;
Having created a table, we can insert tuples into it. The simplest way to insert is with the &amp;lt;tt&amp;gt;INSERT&amp;lt;/tt&amp;gt; command:&lt;br /&gt;
&lt;br /&gt;
      INSERT INTO &amp;amp;lt;tableName&amp;amp;gt;&lt;br /&gt;
          VALUES( &amp;amp;lt;list of values for attributes, in order&amp;amp;gt; );&lt;br /&gt;
&lt;br /&gt;
For instance, we can insert the tuple &amp;lt;tt&amp;gt;(10, 'foobar')&amp;lt;/tt&amp;gt; into relation &amp;lt;tt&amp;gt;test&amp;lt;/tt&amp;gt; by&lt;br /&gt;
&lt;br /&gt;
      INSERT INTO test VALUES(10, 'foobar');&lt;br /&gt;
&lt;br /&gt;
===---- Getting the Value of a Relation===&lt;br /&gt;
&lt;br /&gt;
We can see the tuples in a relation with the command:&lt;br /&gt;
&lt;br /&gt;
      SELECT *&lt;br /&gt;
      FROM &amp;amp;lt;tableName&amp;amp;gt;;&lt;br /&gt;
&lt;br /&gt;
For instance, after the above create and insert statements, the command&lt;br /&gt;
&lt;br /&gt;
      SELECT * FROM test;&lt;br /&gt;
&lt;br /&gt;
produces the result&lt;br /&gt;
&lt;br /&gt;
               I S&lt;br /&gt;
      ---------- ----------&lt;br /&gt;
              10 foobar&lt;br /&gt;
&lt;br /&gt;
===---- Getting Rid of Your Tables===&lt;br /&gt;
&lt;br /&gt;
To remove a table from your database, execute&lt;br /&gt;
&lt;br /&gt;
      DROP TABLE &amp;amp;lt;tableName&amp;amp;gt;;&lt;br /&gt;
&lt;br /&gt;
We suggest you execute&lt;br /&gt;
&lt;br /&gt;
      DROP TABLE test;&lt;br /&gt;
&lt;br /&gt;
after trying out this sequence of commands to avoid leaving a lot of garbage around that will be still there the next time you use the Oracle system.&lt;br /&gt;
&lt;br /&gt;
===---- Getting Information About Your Database===&lt;br /&gt;
&lt;br /&gt;
The system keeps information about your own database in certain system tables. The most important for now is &amp;lt;tt&amp;gt;USER_TABLES&amp;lt;/tt&amp;gt;. You can recall the names of your tables by issuing the query:&lt;br /&gt;
&lt;br /&gt;
      SELECT TABLE_NAME&lt;br /&gt;
      FROM USER_TABLES;&lt;br /&gt;
&lt;br /&gt;
More information about your tables is available from &amp;lt;tt&amp;gt;USER_TABLES&amp;lt;/tt&amp;gt;. To see all the attributes of &amp;lt;tt&amp;gt;USER_TABLES&amp;lt;/tt&amp;gt;, try:&lt;br /&gt;
&lt;br /&gt;
      SELECT *&lt;br /&gt;
      FROM USER_TABLES;&lt;br /&gt;
&lt;br /&gt;
It is also possible to recall the attributes of a table once you know its name. Issue the command:&lt;br /&gt;
&lt;br /&gt;
      DESCRIBE &amp;amp;lt;tableName&amp;amp;gt;;&lt;br /&gt;
&lt;br /&gt;
to learn about the attributes of relation &amp;lt;tt&amp;gt;&amp;amp;lt;tableName&amp;amp;gt;&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===---- Quitting &amp;lt;tt&amp;gt;sqlplus&amp;lt;/tt&amp;gt;===&lt;br /&gt;
&lt;br /&gt;
To leave &amp;lt;tt&amp;gt;sqlplus&amp;lt;/tt&amp;gt;, type&lt;br /&gt;
&lt;br /&gt;
      quit;&lt;br /&gt;
&lt;br /&gt;
in response to the &amp;lt;tt&amp;gt;SQL&amp;amp;gt;&amp;lt;/tt&amp;gt; prompt.&lt;br /&gt;
&lt;br /&gt;
===---- Executing SQL From a File===&lt;br /&gt;
&lt;br /&gt;
Instead of executing SQL commands typed at a terminal, it is often more convenient to type the SQL command(s) into a file and cause the file to be executed. There are two ways to do so.&lt;br /&gt;
&lt;br /&gt;
The first is to provide your password and the name of the file in the command line with which you open &amp;lt;tt&amp;gt;sqlplus&amp;lt;/tt&amp;gt;. The form of the command is:&lt;br /&gt;
&lt;br /&gt;
      sqlplus &amp;amp;lt;yourName&amp;amp;gt;/&amp;amp;lt;yourPassword&amp;amp;gt; @&amp;amp;lt;fileName&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
For instance, if user &amp;lt;tt&amp;gt;sally&amp;lt;/tt&amp;gt;, whose password is &amp;lt;tt&amp;gt;etaoinshrdlu&amp;lt;/tt&amp;gt;, wishes to execute the file &amp;lt;tt&amp;gt;foo.sql&amp;lt;/tt&amp;gt;, then she would say:&lt;br /&gt;
&lt;br /&gt;
      sqlplus sally/etaoinshrdlu @foo&lt;br /&gt;
&lt;br /&gt;
Notice that this mode presents a risk that &amp;lt;tt&amp;gt;sally&amp;lt;/tt&amp;gt;'s password will be discovered, so it should be used carefully. Also note that since &amp;lt;tt&amp;gt;sally&amp;lt;/tt&amp;gt; did not specify an extension for the file name &amp;quot;&amp;lt;tt&amp;gt;foo&amp;lt;/tt&amp;gt;&amp;quot;,  &amp;lt;tt&amp;gt;sqlplus&amp;lt;/tt&amp;gt; implicitly assumes the default extension &amp;quot;&amp;lt;tt&amp;gt;.sql&amp;lt;/tt&amp;gt;&amp;quot;. Therefore, it is a good idea to give every command file an extension, and specify the complete file name with the extension after the &amp;quot;&amp;lt;tt&amp;gt;@&amp;lt;/tt&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A second, safer way, is for &amp;lt;tt&amp;gt;sally&amp;lt;/tt&amp;gt; to log in to &amp;lt;tt&amp;gt;sqlplus&amp;lt;/tt&amp;gt; as usual. She then types, in response to the &amp;lt;tt&amp;gt;SQL&amp;amp;gt;&amp;lt;/tt&amp;gt; prompt:&lt;br /&gt;
&lt;br /&gt;
      @foo.sql&lt;br /&gt;
&lt;br /&gt;
and the file &amp;lt;tt&amp;gt;foo.sql&amp;lt;/tt&amp;gt;'s contents will be executed.&lt;br /&gt;
&lt;br /&gt;
===---- Editing Commands in the Buffer===&lt;br /&gt;
&lt;br /&gt;
If you end a command without a semicolon, but with an empty new line, the command goes into a buffer. You may execute the command in the buffer by either the command &amp;lt;tt&amp;gt;RUN&amp;lt;/tt&amp;gt; or a single slash (/).&lt;br /&gt;
&lt;br /&gt;
You may also edit the command in the buffer before you execute it. Here are some useful editing commands. They are shown in upper case but may be either upper or lower.&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;100%&amp;quot; border=&amp;quot;BORDER&amp;quot;&lt;br /&gt;
| &amp;lt;tt&amp;gt;L&amp;lt;/tt&amp;gt;&lt;br /&gt;
| lists the command buffer, and makes the last line in the buffer the &amp;quot;current&amp;quot; line&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;L&amp;lt;/tt&amp;gt; ''n''&lt;br /&gt;
| prints line ''n'' of the command buffer, and makes line ''n ''the current line&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;L&amp;lt;/tt&amp;gt; ''m n''&lt;br /&gt;
| prints lines ''m'' through ''n'', and makes line ''n'' the current line&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;I&amp;lt;/tt&amp;gt;&lt;br /&gt;
| enters a mode that allows you to input text following the current line; you must terminate the sequence of new lines with a pair of &amp;quot;returns&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;C /old/new&amp;lt;/tt&amp;gt;&lt;br /&gt;
| replaces the text &amp;quot;&amp;lt;tt&amp;gt;old&amp;lt;/tt&amp;gt;&amp;quot; by &amp;quot;&amp;lt;tt&amp;gt;new&amp;lt;/tt&amp;gt;&amp;quot; in the current line&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;A text&amp;lt;/tt&amp;gt;&lt;br /&gt;
| appends &amp;quot;&amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt;&amp;quot; to the end of the current line&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;tt&amp;gt;DEL&amp;lt;/tt&amp;gt;&lt;br /&gt;
| deletes the current line&lt;br /&gt;
|}===---- Recording Your Session===&lt;br /&gt;
&lt;br /&gt;
There are several methods for creating a typescript to turn in for your programming assignments. The most primitive way is to cut and paste your terminal output and save it in a file (if you have windowing capabilities). Another method is to use the Unix command &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; to record the terminal interaction. The &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt; command records everything printed on your screen. The syntax for the command is&lt;br /&gt;
&lt;br /&gt;
     script [ -a ] [ filename ]&lt;br /&gt;
&lt;br /&gt;
The record is written to &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;. If no file name is given, the record is saved in the file &amp;lt;tt&amp;gt;typescript&amp;lt;/tt&amp;gt;. The &amp;lt;tt&amp;gt;-a &amp;lt;/tt&amp;gt;option allows you to append the session record to &amp;lt;tt&amp;gt;filename&amp;lt;/tt&amp;gt;, rather than overwrite it. To end the recording, type&lt;br /&gt;
&lt;br /&gt;
     exit&lt;br /&gt;
&lt;br /&gt;
For more information about &amp;lt;tt&amp;gt;script&amp;lt;/tt&amp;gt;, check out its man page.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can use the &amp;lt;tt&amp;gt;spool&amp;lt;/tt&amp;gt; command within &amp;lt;tt&amp;gt;sqlplus&amp;lt;/tt&amp;gt;. At the &amp;lt;tt&amp;gt;SQL&amp;amp;gt;&amp;lt;/tt&amp;gt; prompt, you say:&lt;br /&gt;
&lt;br /&gt;
     spool foo;&lt;br /&gt;
&lt;br /&gt;
and a file called &amp;lt;tt&amp;gt;foo.lst&amp;lt;/tt&amp;gt; will appear in your current directory and will hold everything typed, until you exit &amp;lt;tt&amp;gt;sqlplus&amp;lt;/tt&amp;gt; or type:&lt;br /&gt;
&lt;br /&gt;
     spool off;&lt;br /&gt;
&lt;br /&gt;
Finally, if you use Emacs, you can simply run &amp;lt;tt&amp;gt;sqlplus&amp;lt;/tt&amp;gt; in a shell buffer and save the buffer to a file. To prevent your Oracle password from being echoed in the Emacs buffer, add the following lines to your &amp;lt;tt&amp;gt;.emacs&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
 (setq-default&lt;br /&gt;
  comint-output-filter-functions&lt;br /&gt;
  '(comint-watch-for-password-prompt))&lt;br /&gt;
 (setq&lt;br /&gt;
  comint-password-prompt-regexp&lt;br /&gt;
  &amp;quot;\\(\\([Oo]ld \\|[Nn]ew \\|^\\)[Pp]assword\\|Enter password\\):\\s *\\'&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
===---- Help Facilities and Other Hints===&lt;br /&gt;
&lt;br /&gt;
In response to the &amp;lt;tt&amp;gt;SQL&amp;amp;gt;&amp;lt;/tt&amp;gt; prompt, type &amp;lt;tt&amp;gt;help&amp;lt;/tt&amp;gt; followed by a keyword. If you are lucky, the keyword will be one of those for which help exists, and you will get a (somewhat) helpful message, usually ending in an example or two. To see all the possible commands, for each of which help is available, type&lt;br /&gt;
&lt;br /&gt;
     help commands;&lt;br /&gt;
&lt;br /&gt;
The output from &amp;lt;tt&amp;gt;help&amp;lt;/tt&amp;gt;, and in general, the results of many SQL commands, can be too long to display on a screen. You can use&lt;br /&gt;
&lt;br /&gt;
     set pause on;&lt;br /&gt;
&lt;br /&gt;
to activate the paging feature.  When this feature is activated, output will pause at the end of each screen until you hit the &amp;quot;return&amp;quot; key. To turn this feature off, use&lt;br /&gt;
&lt;br /&gt;
     set pause off;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;font size=&amp;quot;-2&amp;quot;&amp;gt;This document was written originally for Prof. Jeff Ullman's CS145 class in Autumn, 1997; revised by Jun Yang for Prof. Jennifer Widom's CS145 class in Spring, 1998.&amp;lt;/font&amp;gt;&lt;/div&gt;</summary>
		<author><name>MassBot1</name></author>
	</entry>
</feed>