Difference between revisions of "Oracle:Initial Queries"

From mi-linux
Jump to navigationJump to search
Line 15: Line 15:
 
Note, describe is a command proprietary to Oracle and is not part of the SQL standard. These commands are part of the Plus commands Oracle provides and do not need a semi-colon after them.
 
Note, describe is a command proprietary to Oracle and is not part of the SQL standard. These commands are part of the Plus commands Oracle provides and do not need a semi-colon after them.
  
== Exercise 1 ==
+
== Exercise 1.1 ==
  
 
Type in the SQL code to display the structure of the CUSTOMER table.
 
Type in the SQL code to display the structure of the CUSTOMER table.
Line 21: Line 21:
 
The result should be similar to the following:
 
The result should be similar to the following:
  
 +
<pre style="color: blue">
 
  Name                                      Null?    Type
 
  Name                                      Null?    Type
 
  ----------------------------------------- -------- ----------------------------
 
  ----------------------------------------- -------- ----------------------------
Line 31: Line 32:
 
  DESCRIPTION                                        VARCHAR2(20)
 
  DESCRIPTION                                        VARCHAR2(20)
 
  QTY                                                NUMBER(4)
 
  QTY                                                NUMBER(4)
 +
</pre>
  
 
Type in the following commands separately:
 
Type in the following commands separately:

Revision as of 13:25, 17 February 2016

Main Page >> Oracle and SQL >> Getting Started >> Initial Queries

Initial Queries

Try the following commands and exercises:

Getting Information about the Attributes of a Table

To get a description of a particular table use the DESCRIBE command.

To describe the table EMP:

 describe emp 

Note, describe is a command proprietary to Oracle and is not part of the SQL standard. These commands are part of the Plus commands Oracle provides and do not need a semi-colon after them.

Exercise 1.1

Type in the SQL code to display the structure of the CUSTOMER table.

The result should be similar to the following:

 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 CNO                                                NUMBER(4)
 ORDERDATE                                          DATE
 NAME                                               VARCHAR2(15)
 CITY                                               VARCHAR2(15)
 COUNTRY                                            VARCHAR2(15)
 PNO                                                NUMBER(4)
 DESCRIPTION                                        VARCHAR2(20)
 QTY                                                NUMBER(4)

Type in the following commands separately:

 describe dept
 select * from dept;
 select * from emp;
 describe salgrade
 select * from salgrade;


Make notes on how the results differ.

Next Step

This concludes setting up the Oracle database. Return now to the Workbook for the next section.