Oracle PL/SQL/Index/Create Index — различия между версиями

Материал из SQL эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 10:02, 26 мая 2010

Create a fully indexed table named myCode

    
SQL>
SQL> create table myCode(
  2    codeValue  VARCHAR2(1) primary key,
  3    Description VARCHAR2(25)
  4  );
Table created.
SQL>
SQL> create index i1 on myCode (codeValue, Description);
Index created.
SQL>
SQL>
SQL> drop index i1;
Index dropped.
SQL>
SQL> drop table myCode;
Table dropped.



Create an index, and add primary key to use that index

    
SQL>
SQL>
SQL> create table inventory(
  2  partno number(4),
  3  partdesc varchar2(35),
  4  price number(8,2),
  5  warehouse varchar2(15));
Table created.
SQL>
SQL> Create index invent_part_loc_idx
  2  On inventory (partno, warehouse)
  3  Pctfree 10;
Index created.
SQL>
SQL> Alter table inventory add (
  2  Constraint invent_partno_pk primary key (partno)
  3  Using index invent_part_loc_idx);
Table altered.
SQL>
SQL> drop table inventory;
Table dropped.
SQL>



Create an index reverse

    
SQL>
SQL> CREATE TABLE EMP (EMPNO NUMBER(4) NOT NULL,
  2                    ENAME VARCHAR2(10),
  3                    JOB VARCHAR2(9),
  4                    MGR NUMBER(4),
  5                    HIREDATE DATE,
  6                    SAL NUMBER(7, 2),
  7                    COMM NUMBER(7, 2),
  8                    DEPTNO NUMBER(2));
Table created.
SQL>
SQL> create index emp_empno_pk
  2  on emp(empno) reverse;
Index created.
SQL>
SQL> drop table emp;
Table dropped.
SQL>



Created an index based on the uppercase evaluation of the employe"s first name field

   

SQL> -- create demo table
SQL> create table Employee(
  2    ID                 VARCHAR2(4 BYTE)         NOT NULL,
  3    First_Name         VARCHAR2(10 BYTE),
  4    Last_Name          VARCHAR2(10 BYTE),
  5    Start_Date         DATE,
  6    End_Date           DATE,
  7    Salary             Number(8,2),
  8    City               VARCHAR2(10 BYTE),
  9    Description        VARCHAR2(15 BYTE)
 10  )
 11  /
Table created.
SQL>
SQL> -- prepare data
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2               values ("01","Jason",    "Martin",  to_date("19960725","YYYYMMDD"), to_date("20060725","YYYYMMDD"), 1234.56, "Toronto",  "Programmer")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2                values("02","Alison",   "Mathews", to_date("19760321","YYYYMMDD"), to_date("19860221","YYYYMMDD"), 6661.78, "Vancouver","Tester")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2                values("03","James",    "Smith",   to_date("19781212","YYYYMMDD"), to_date("19900315","YYYYMMDD"), 6544.78, "Vancouver","Tester")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2                values("04","Celia",    "Rice",    to_date("19821024","YYYYMMDD"), to_date("19990421","YYYYMMDD"), 2344.78, "Vancouver","Manager")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2                values("05","Robert",   "Black",   to_date("19840115","YYYYMMDD"), to_date("19980808","YYYYMMDD"), 2334.78, "Vancouver","Tester")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary, City,        Description)
  2                values("06","Linda",    "Green",   to_date("19870730","YYYYMMDD"), to_date("19960104","YYYYMMDD"), 4322.78,"New York",  "Tester")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary, City,        Description)
  2                values("07","David",    "Larry",   to_date("19901231","YYYYMMDD"), to_date("19980212","YYYYMMDD"), 7897.78,"New York",  "Manager")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary, City,        Description)
  2                values("08","James",    "Cat",     to_date("19960917","YYYYMMDD"), to_date("20020415","YYYYMMDD"), 1232.78,"Vancouver", "Tester")
  3  /
1 row created.
SQL>
SQL>
SQL>
SQL> -- display data in the table
SQL> select * from Employee
  2  /
ID   FIRST_NAME LAST_NAME  START_DAT END_DATE      SALARY CITY       DESCRIPTION
---- ---------- ---------- --------- --------- ---------- ---------- ---------------
01   Jason      Martin     25-JUL-96 25-JUL-06    1234.56 Toronto    Programmer
02   Alison     Mathews    21-MAR-76 21-FEB-86    6661.78 Vancouver  Tester
03   James      Smith      12-DEC-78 15-MAR-90    6544.78 Vancouver  Tester
04   Celia      Rice       24-OCT-82 21-APR-99    2344.78 Vancouver  Manager
05   Robert     Black      15-JAN-84 08-AUG-98    2334.78 Vancouver  Tester
06   Linda      Green      30-JUL-87 04-JAN-96    4322.78 New York   Tester
07   David      Larry      31-DEC-90 12-FEB-98    7897.78 New York   Manager
08   James      Cat        17-SEP-96 15-APR-02    1232.78 Vancouver  Tester
8 rows selected.
SQL>
SQL>
SQL> -- Created an index based on the uppercase evaluation of the employe"s first name field.
SQL>
SQL>  CREATE INDEX employee_idx
  2         ON employee (UPPER(first_name));
Index created.
SQL>
SQL>  drop index employee_idx;
Index dropped.
SQL>
SQL> -- clean the table
SQL> drop table Employee
  2  /
Table dropped.
SQL>



Create index along with the column definition

    
SQL>
SQL>
SQL> CREATE TABLE emp2
  2  (emp_id        NUMBER PRIMARY KEY
  3                  USING INDEX
  4                  (CREATE INDEX pk_idx ON emp2(emp_id) TABLESPACE users)
  5   ,lastname      VARCHAR2(20) CONSTRAINT lastname_create_nn NOT NULL
  6   ,firstname     VARCHAR2(15) CONSTRAINT firstname_create_nn NOT NULL
  7   ,phone     VARCHAR2(12)
  8   ,company_name  VARCHAR2(50)
  9   ,CONSTRAINT unique_emp_phone UNIQUE (phone)
 10    USING INDEX
 11   (CREATE INDEX phone_idx ON emp2 (phone) TABLESPACE users)
 12   );
Table created.
SQL>
SQL>
SQL> drop table emp2;
Table dropped.



Create index for combined columns

    
SQL>
SQL> create table emp(
  2           emp_id            integer         primary key
  3          ,lastname               varchar2(20)    not null
  4          ,firstname              varchar2(15)    not null
  5          ,midinit                varchar2(1)
  6          ,street                 varchar2(30)
  7          ,city                   varchar2(20)
  8          ,state                  varchar2(2)
  9          ,zip                    varchar2(5)
 10          ,shortZipCode           varchar2(4)
 11          ,area_code              varchar2(3)
 12          ,phone                  varchar2(8)
 13          ,company_name           varchar2(50));
Table created.
SQL>
SQL> create index fullname on emp(lastname, firstname);
Index created.
SQL>
SQL>
SQL> drop table emp;
Table dropped.
SQL>
SQL>



Create index for upper case last name

    
SQL>
SQL> create table emp(
  2           emp_id                integer         primary key
  3          ,lastname               varchar2(20)    not null
  4          ,firstname              varchar2(15)    not null
  5          ,midinit                varchar2(1)
  6          ,street                 varchar2(30)
  7          ,city                   varchar2(20)
  8          ,state                  varchar2(2)
  9          ,zip                    varchar2(5)
 10          ,shortZipCode                   varchar2(4)
 11          ,area_code              varchar2(3)
 12          ,phone                  varchar2(8)
 13          ,company_name           varchar2(50));
Table created.
SQL>
SQL> create index upper_emp_idx on emp upper(lastname);
Index created.
SQL>
SQL>
SQL> drop table emp;
Table dropped.



Create index on cluster

    

SQL> create cluster user_objects_cluster_btree
  2  ( username varchar2(30) )
  3  size 1024
  4  /
Cluster created.
SQL>
SQL> create index user_objects_idx
  2  on cluster user_objects_cluster_btree
  3  /
Index created.
SQL>
SQL> drop cluster user_objects_cluster_btree;
Cluster dropped.
SQL>



Create index with tablespace

    

SQL> create table emp (
  2      EmpNo          NUMBER(10) primary key,
  3      Name           VARCHAR2(40),
  4      DeptNo         NUMBER(2),
  5      Salary         NUMBER(7,2),
  6      Birth_Date     DATE,
  7      Soc_Sec_Num    VARCHAR2(9),
  8      State_Code     CHAR(2)
  9  );
SQL>
SQL> create index CITY_ST_ZIP_NDX
  2  on emp(EmpNo, DeptNo, Soc_Sec_Num)
  3  tablespace INDEXES;

SQL>
SQL> drop table emp
  2



Create Non-Unique index

    
SQL>
SQL>
SQL> CREATE TABLE myTable (
  2     myTableID INT PRIMARY KEY NOT NULL,
  3     Name     VARCHAR(50),
  4     PhoneNo  VARCHAR(15) DEFAULT "Unknown Phone");
Table created.
SQL>
SQL>
SQL> CREATE INDEX NameIndex ON myTable (Name);
Index created.

SQL>



Create two indexes for one single table

    

create table indextest as 
select * from dba_objects where owner in ("OUTLN","PUBLIC","SCOTT","SYS","SYSTEM");
create index indxtest_objname_idx on indextest (object_name) pctfree 10;
create index indxtest_objname_fidx on indextest(upper(object_name));
select object_name,owner from indextest
where upper(object_name) ="DBA_INDEXES";
select upper(object_name) from indextest;
alter table indextest modify object_name NOT NULL;
select upper(object_name) from indextest;
drop table indextest;



CREATE UNIQUE INDEX

    
SQL>
SQL> CREATE TABLE myTable (
  2     myTableID INT PRIMARY KEY NOT NULL,
  3     Name     VARCHAR(50),
  4     PhoneNo  VARCHAR(15) DEFAULT "Unknown Phone");
Table created.
SQL>
SQL> CREATE UNIQUE INDEX NameIndex ON myTable (Name);
Index created.
SQL>
SQL> drop table myTable;
Table dropped.



Create unique index and check it in user_ind_columns and user_cons_columns

    
SQL>
SQL> set echo off
SQL> create table emp(
  2           emp_id            integer     primary key
  3          ,lastname               varchar2(20)    constraint lastname_create_nn not null
  4          ,firstname              varchar2(15)    constraint firstname_create_nn not null
  5          ,midinit                varchar2(1)
  6          ,street                 varchar2(30)
  7          ,city                   varchar2(20)
  8          ,state                  varchar2(2)
  9          ,zip                    varchar2(5)
 10          ,shortZipCode           varchar2(4)
 11          ,area_code              varchar2(3)
 12          ,phone                  varchar2(8)
 13          ,company_name           varchar2(50));
Table created.
SQL>
SQL> create unique index pk_idx on emp (emp_id);
SQL>
SQL> select index_name, table_name, column_name from user_ind_columns where table_name = "EMP";

SQL>
SQL> select constraint_name, table_name, column_name from user_cons_columns where table_name = "EMP";
SQL>
SQL>
SQL> drop table emp cascade constraints;
Table dropped.
SQL>



create unique index with case ... when statement

    
SQL> create table registrations
  2  ( attendee    NUMBER(4)
  3  , course      VARCHAR2(6)
  4  , begindate   DATE
  5  , evaluation  NUMBER(1)
  6  , constraint  R_PK        primary key(attendee,course,begindate)
  7  ) ;
Table created.
SQL>
SQL> insert into registrations values (8,"JAV",date "2009-12-13",5   );
1 row created.
SQL> insert into registrations values (9,"JAV",date "2009-12-13",4   );
1 row created.
SQL> insert into registrations values (4,"JAV",date "2000-02-01",3   );
1 row created.
SQL> insert into registrations values (8,"JAV",date "2000-02-01",4   );
1 row created.
SQL> insert into registrations values (6,"JAV",date "2000-02-01",5   );
1 row created.
SQL> insert into registrations values (12,"XML",date "2000-02-03",4   );
1 row created.
SQL> insert into registrations values (2,"XML",date "2000-02-03",5   );
1 row created.
SQL> insert into registrations values (4,"PLS",date "2000-09-11",NULL);
1 row created.
SQL> insert into registrations values (2,"PLS",date "2000-09-11",NULL);
1 row created.
SQL> insert into registrations values (11,"PLS",date "2000-09-11",NULL);
1 row created.
SQL>
SQL> create unique index oau_reg on registrations
  2  ( case course when "OAU" then attendee else null end
  3  , case course when "OAU" then course   else null end );
Index created.
SQL>
SQL> insert into registrations values (12,"OAU",sysdate,null);
1 row created.
SQL>
SQL> drop index oau_reg;
Index dropped.
SQL> drop table registrations;
Table dropped.



Demonstrate a bitmap join index.

    
SQL>
SQL>
SQL> CREATE TABLE EMP(
  2      EMPNO NUMBER(4) NOT NULL,
  3      ENAME VARCHAR2(10),
  4      JOB VARCHAR2(9),
  5      MGR NUMBER(4),
  6      startDate DATE,
  7      SAL NUMBER(7, 2),
  8      COMM NUMBER(7, 2),
  9      DEPTNO NUMBER(2)
 10  );
Table created.
SQL>
SQL> INSERT INTO EMP VALUES(7369, "SMITH", "CLERK", 7902,TO_DATE("17-DEC-1980", "DD-MON-YYYY"), 800, NULL, 20);
1 row created.
SQL> INSERT INTO EMP VALUES(7499, "ALLEN", "SALESMAN", 7698,TO_DATE("20-FEB-1981", "DD-MON-YYYY"), 1600, 300, 30);
1 row created.
SQL> INSERT INTO EMP VALUES(7521, "WARD", "SALESMAN", 7698,TO_DATE("22-FEB-1981", "DD-MON-YYYY"), 1250, 500, 30);
1 row created.
SQL> INSERT INTO EMP VALUES(7566, "JONES", "MANAGER", 7839,TO_DATE("2-APR-1981", "DD-MON-YYYY"), 2975, NULL, 20);
1 row created.
SQL> INSERT INTO EMP VALUES(7654, "MARTIN", "SALESMAN", 7698,TO_DATE("28-SEP-1981", "DD-MON-YYYY"), 1250, 1400, 30);
1 row created.
SQL> INSERT INTO EMP VALUES(7698, "BLAKE", "MANAGER", 7839,TO_DATE("1-MAY-1981", "DD-MON-YYYY"), 2850, NULL, 30);
1 row created.
SQL> INSERT INTO EMP VALUES(7782, "CLARK", "MANAGER", 7839,TO_DATE("9-JUN-1981", "DD-MON-YYYY"), 2450, NULL, 10);
1 row created.
SQL> INSERT INTO EMP VALUES(7788, "SCOTT", "ANALYST", 7566,TO_DATE("09-DEC-1982", "DD-MON-YYYY"), 3000, NULL, 20);
1 row created.
SQL> INSERT INTO EMP VALUES(7839, "KING", "PRESIDENT", NULL,TO_DATE("17-NOV-1981", "DD-MON-YYYY"), 5000, NULL, 10);
1 row created.
SQL> INSERT INTO EMP VALUES(7844, "TURNER", "SALESMAN", 7698,TO_DATE("8-SEP-1981", "DD-MON-YYYY"), 1500, 0, 30);
1 row created.
SQL> INSERT INTO EMP VALUES(7876, "ADAMS", "CLERK", 7788,TO_DATE("12-JAN-1983", "DD-MON-YYYY"), 1100, NULL, 20);
1 row created.
SQL> INSERT INTO EMP VALUES(7900, "E", "CLERK", 7698,TO_DATE("3-DEC-1981", "DD-MON-YYYY"), 950, NULL, 30);
1 row created.
SQL> INSERT INTO EMP VALUES(7902, "FORD", "ANALYST", 7566,TO_DATE("3-DEC-1981", "DD-MON-YYYY"), 3000, NULL, 20);
1 row created.
SQL> INSERT INTO EMP VALUES(7934, "MILLER", "CLERK", 7782,TO_DATE("23-JAN-1982", "DD-MON-YYYY"), 1300, NULL, 10);
1 row created.
SQL>
SQL> CREATE TABLE DEPT(
  2      DEPTNO NUMBER(2),
  3      DNAME VARCHAR2(14),
  4      LOC VARCHAR2(13)
  5  );
Table created.
SQL>
SQL> INSERT INTO DEPT VALUES (10, "ACCOUNTING", "NEW YORK");
1 row created.
SQL> INSERT INTO DEPT VALUES (20, "RESEARCH", "DALLAS");
1 row created.
SQL> INSERT INTO DEPT VALUES (30, "SALES", "CHICAGO");
1 row created.
SQL> INSERT INTO DEPT VALUES (40, "OPERATIONS", "BOSTON");
1 row created.
SQL>
SQL> select count(*) from emp, dept where emp.deptno = dept.deptno and dept.dname = "SALES";
  COUNT(*)
----------
         6
1 row selected.

Execution Plan
----------------------------------------------------------
Plan hash value: 2157540364
-------------------------------------
| Id  | Operation            | Name |
-------------------------------------
|   0 | SELECT STATEMENT     |      |
|   1 |  SORT AGGREGATE      |      |
|   2 |   MERGE JOIN         |      |
|   3 |    SORT JOIN         |      |
|*  4 |     TABLE ACCESS FULL| DEPT |
|*  5 |    SORT JOIN         |      |
|   6 |     TABLE ACCESS FULL| EMP  |
-------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   4 - filter("DEPT"."DNAME"="SALES")
   5 - access("EMP"."DEPTNO"="DEPT"."DEPTNO")
       filter("EMP"."DEPTNO"="DEPT"."DEPTNO")
Note
-----
   - rule based optimizer used (consider using cbo)

Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
          6  consistent gets
          0  physical reads
          0  redo size
        411  bytes sent via SQL*Net to client
        380  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          2  sorts (memory)
          0  sorts (disk)
          1  rows processed
SQL>
SQL> set autotrace off;
SQL>
SQL> drop table emp;
Table dropped.
SQL> drop table dept;
Table dropped.
SQL>
SQL>



Function-based Indexes

    
SQL>
SQL> CREATE TABLE EMP (EMPNO NUMBER(4) NOT NULL,
  2                    ENAME VARCHAR2(10),
  3                    JOB VARCHAR2(9),
  4                    MGR NUMBER(4),
  5                    HIREDATE DATE,
  6                    SAL NUMBER(7, 2),
  7                    COMM NUMBER(7, 2),
  8                    DEPTNO NUMBER(2));
Table created.
SQL>
SQL> create index upper_name_idx on emp(upper(ename));
Index created.
SQL>
SQL>
SQL> drop table EMP;
Table dropped.
SQL>
SQL>



indextype is ctxsys.context

    
SQL>
SQL>
SQL> create table t ( x clob );
Table created.
SQL>
SQL> set autotrace traceonly explain
SQL> select * from t;
Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873
----------------------------------
| Id  | Operation         | Name |
----------------------------------
|   0 | SELECT STATEMENT  |      |
|   1 |  TABLE ACCESS FULL| T    |
----------------------------------
Note
-----
   - rule based optimizer used (consider using cbo)
SQL>
SQL> create index t_idx on t(x) indextype is ctxsys.context;
Index created.
SQL> select * from t;
Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873
----------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost  |
----------------------------------------------------------
|   0 | SELECT STATEMENT  |      |    82 |  8200 |     1 |
|   1 |  TABLE ACCESS FULL| T    |    82 |  8200 |     1 |
----------------------------------------------------------
Note
-----
   - cpu costing is off (consider enabling it)
SQL>
SQL> set autotrace off
SQL>
SQL> drop table t;
Table dropped.



simple index organized table

    
SQL>
SQL> create table states (
  2        state_id         varchar2(2),
  3        state_name       varchar2(20),
  4        constraint states_pk
  5          primary key (state_id)
  6  )
  7  organization index
  8  /
Table created.
SQL>
SQL> drop table states;
Table dropped.
SQL>



To create an index on the LastName column of the Employee table

   

SQL> -- create demo table
SQL> create table Employee(
  2    ID                 VARCHAR2(4 BYTE)         NOT NULL,
  3    First_Name         VARCHAR2(10 BYTE),
  4    Last_Name          VARCHAR2(10 BYTE),
  5    Start_Date         DATE,
  6    End_Date           DATE,
  7    Salary             Number(8,2),
  8    City               VARCHAR2(10 BYTE),
  9    Description        VARCHAR2(15 BYTE)
 10  )
 11  /
Table created.
SQL>
SQL> -- prepare data
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2               values ("01","Jason",    "Martin",  to_date("19960725","YYYYMMDD"), to_date("20060725","YYYYMMDD"), 1234.56, "Toronto",  "Programmer")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2                values("02","Alison",   "Mathews", to_date("19760321","YYYYMMDD"), to_date("19860221","YYYYMMDD"), 6661.78, "Vancouver","Tester")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2                values("03","James",    "Smith",   to_date("19781212","YYYYMMDD"), to_date("19900315","YYYYMMDD"), 6544.78, "Vancouver","Tester")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2                values("04","Celia",    "Rice",    to_date("19821024","YYYYMMDD"), to_date("19990421","YYYYMMDD"), 2344.78, "Vancouver","Manager")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2                values("05","Robert",   "Black",   to_date("19840115","YYYYMMDD"), to_date("19980808","YYYYMMDD"), 2334.78, "Vancouver","Tester")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary, City,        Description)
  2                values("06","Linda",    "Green",   to_date("19870730","YYYYMMDD"), to_date("19960104","YYYYMMDD"), 4322.78,"New York",  "Tester")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary, City,        Description)
  2                values("07","David",    "Larry",   to_date("19901231","YYYYMMDD"), to_date("19980212","YYYYMMDD"), 7897.78,"New York",  "Manager")
  3  /
1 row created.
SQL> insert into Employee(ID,  First_Name, Last_Name, Start_Date,                     End_Date,                       Salary, City,        Description)
  2                values("08","James",    "Cat",     to_date("19960917","YYYYMMDD"), to_date("20020415","YYYYMMDD"), 1232.78,"Vancouver", "Tester")
  3  /
1 row created.
SQL>
SQL>
SQL>
SQL> -- display data in the table
SQL> select * from Employee
  2  /
ID   FIRST_NAME LAST_NAME  START_DAT END_DATE      SALARY CITY       DESCRIPTION
---- ---------- ---------- --------- --------- ---------- ---------- ---------------
01   Jason      Martin     25-JUL-96 25-JUL-06    1234.56 Toronto    Programmer
02   Alison     Mathews    21-MAR-76 21-FEB-86    6661.78 Vancouver  Tester
03   James      Smith      12-DEC-78 15-MAR-90    6544.78 Vancouver  Tester
04   Celia      Rice       24-OCT-82 21-APR-99    2344.78 Vancouver  Manager
05   Robert     Black      15-JAN-84 08-AUG-98    2334.78 Vancouver  Tester
06   Linda      Green      30-JUL-87 04-JAN-96    4322.78 New York   Tester
07   David      Larry      31-DEC-90 12-FEB-98    7897.78 New York   Manager
08   James      Cat        17-SEP-96 15-APR-02    1232.78 Vancouver  Tester
8 rows selected.
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> --To create an index on the LastName column of the Employee table
SQL>
SQL>  CREATE INDEX LastNameIndex
  2   ON Employee (Last_Name);
Index created.
SQL>
SQL>
SQL>  drop index LastNameIndex;
Index dropped.
SQL>
SQL>
SQL>
SQL>
SQL> -- clean the table
SQL> drop table Employee
  2  /
Table dropped.
SQL>
SQL>
SQL>