상세 컨텐츠

본문 제목

[Data Base] 2019.06.24. 기록. 실습내용

1 a n G u a g e /DB

by 동혼 2019. 8. 24. 22:23

본문


SQL*Plus: Release 11.2.0.2.0 Production on 월 6월 24 09:13:31 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

SQL> conn hr/hr
Connected.
SQL> create view empvu80
  2  as eselect employee_id, last_name, salary
  3  from employees
  4  whrer departement_id = 80;
as eselect employee_id, last_name, salary
   *
ERROR at line 2:
ORA-00928: missing SELECT keyword


SQL> ed
Wrote file afiedt.buf

  1  create view empvu80
  2  as select employee_id, last_name, salary
  3  from employees
  4* whrer departement_id = 80
SQL> ;
  1  create view empvu80
  2  as select employee_id, last_name, salary
  3  from employees
  4* whrer departement_id = 80
SQL>
SQL>
SQL>
SQL>
SQL> ;
  1  create view empvu80
  2  as select employee_id, last_name, salary
  3  from employees
  4* whrer departement_id = 80
SQL> /
whrer departement_id = 80
      *
ERROR at line 4:
ORA-00933: SQL command not properly ended


SQL> ed
Wrote file afiedt.buf

  1  create view empvu80
  2  as select employee_id, last_name, salary
  3  from employees
  4* where departement_id = 80
SQL> /
where departement_id = 80
      *
ERROR at line 4:
ORA-00904: "DEPARTEMENT_ID": invalid identifier


SQL> ed
Wrote file afiedt.buf

  1  create view empvu80
  2  as select employee_id, last_name, salary
  3  from employees
  4* where department_id = 80
SQL> /

View created.

SQL>
SQL>
SQL> desc departement_80=80
SP2-0565: Illegal identifier.
SQL> desc departement_id=80
SP2-0565: Illegal identifier.
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> desc department_id=80
SP2-0565: Illegal identifier.
SQL> desc department_id=80;
SP2-0565: Illegal identifier.
SQL> desc department_id=80/
SP2-0565: Illegal identifier.
SQL>
SQL>
SQL> create view salvu50
  2  as select employee_id ID_NUMBER, last_name NAME, salary*12 ANN_SALARY
  3  from employees
  4  where department_id = 50;

View created.

SQL> select * from salvu50
  2  /

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       120 Weiss                                                   96000
       121 Fripp                                                   98400
       122 Kaufling                                                94800
       123 Vollman                                                 78000
       124 Mourgos                                                 69600
       125 Nayer                                                   38400
       126 Mikkilineni                                             32400
       127 Landry                                                  28800
       128 Markle                                                  26400
       129 Bissot                                                  39600
       130 Atkinson                                                33600

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       131 Marlow                                                  30000
       132 Olson                                                   25200
       133 Mallin                                                  39600
       134 Rogers                                                  34800
       135 Gee                                                     28800
       136 Philtanker                                              26400
       137 Ladwig                                                  43200
       138 Stiles                                                  38400
       139 Seo                                                     32400
       140 Patel                                                   30000
       141 Rajs                                                    42000

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       142 Davies                                                  37200
       143 Matos                                                   31200
       144 Vargas                                                  30000
       180 Taylor                                                  38400
       181 Fleaur                                                  37200
       182 Sullivan                                                30000
       183 Geoni                                                   33600
       184 Sarchand                                                50400
       185 Bull                                                    49200
       186 Dellinger                                               40800
       187 Cabrio                                                  36000

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       188 Chung                                                   45600
       189 Dilly                                                   43200
       190 Gates                                                   34800
       191 Perkins                                                 30000
       192 Bell                                                    48000
       193 Everett                                                 46800
       194 McCain                                                  38400
       195 Jones                                                   33600
       196 Walsh                                                   37200
       197 Feeney                                                  36000
       198 OConnell                                                31200

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       199 Grant                                                   31200

45 rows selected.

SQL> create table salvu50
  2  as select employee_id ID_NUMBER , last_name NAME, salary*12 ANN_SALARY
  3  from emeployees
  4  where department_id = 50 ;
from emeployees
     *
ERROR at line 3:
ORA-00942: table or view does not exist


SQL> ed
Wrote file afiedt.buf

  1  create table salvu50
  2  as select employee_id ID_NUMBER , last_name NAME, salary*12 ANN_SALARY
  3  from employees
  4* where department_id = 50
SQL> /
create table salvu50
             *
ERROR at line 1:
ORA-00955: name is already used by an existing object


SQL> ed
Wrote file afiedt.buf

  1  create table empsalvu50
  2  as select employee_id ID_NUMBER , last_name NAME, salary*12 ANN_SALARY
  3  from employees
  4* where department_id = 50
SQL> /

Table created.

SQL> select * from salyu50
  2  /
select * from salyu50
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from salvu50;

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       120 Weiss                                                   96000
       121 Fripp                                                   98400
       122 Kaufling                                                94800
       123 Vollman                                                 78000
       124 Mourgos                                                 69600
       125 Nayer                                                   38400
       126 Mikkilineni                                             32400
       127 Landry                                                  28800
       128 Markle                                                  26400
       129 Bissot                                                  39600
       130 Atkinson                                                33600

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       131 Marlow                                                  30000
       132 Olson                                                   25200
       133 Mallin                                                  39600
       134 Rogers                                                  34800
       135 Gee                                                     28800
       136 Philtanker                                              26400
       137 Ladwig                                                  43200
       138 Stiles                                                  38400
       139 Seo                                                     32400
       140 Patel                                                   30000
       141 Rajs                                                    42000

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       142 Davies                                                  37200
       143 Matos                                                   31200
       144 Vargas                                                  30000
       180 Taylor                                                  38400
       181 Fleaur                                                  37200
       182 Sullivan                                                30000
       183 Geoni                                                   33600
       184 Sarchand                                                50400
       185 Bull                                                    49200
       186 Dellinger                                               40800
       187 Cabrio                                                  36000

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       188 Chung                                                   45600
       189 Dilly                                                   43200
       190 Gates                                                   34800
       191 Perkins                                                 30000
       192 Bell                                                    48000
       193 Everett                                                 46800
       194 McCain                                                  38400
       195 Jones                                                   33600
       196 Walsh                                                   37200
       197 Feeney                                                  36000
       198 OConnell                                                31200

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       199 Grant                                                   31200

45 rows selected.

SQL> select * from empsalvu50;

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       120 Weiss                                                   96000
       121 Fripp                                                   98400
       122 Kaufling                                                94800
       123 Vollman                                                 78000
       124 Mourgos                                                 69600
       125 Nayer                                                   38400
       126 Mikkilineni                                             32400
       127 Landry                                                  28800
       128 Markle                                                  26400
       129 Bissot                                                  39600
       130 Atkinson                                                33600

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       131 Marlow                                                  30000
       132 Olson                                                   25200
       133 Mallin                                                  39600
       134 Rogers                                                  34800
       135 Gee                                                     28800
       136 Philtanker                                              26400
       137 Ladwig                                                  43200
       138 Stiles                                                  38400
       139 Seo                                                     32400
       140 Patel                                                   30000
       141 Rajs                                                    42000

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       142 Davies                                                  37200
       143 Matos                                                   31200
       144 Vargas                                                  30000
       180 Taylor                                                  38400
       181 Fleaur                                                  37200
       182 Sullivan                                                30000
       183 Geoni                                                   33600
       184 Sarchand                                                50400
       185 Bull                                                    49200
       186 Dellinger                                               40800
       187 Cabrio                                                  36000

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       188 Chung                                                   45600
       189 Dilly                                                   43200
       190 Gates                                                   34800
       191 Perkins                                                 30000
       192 Bell                                                    48000
       193 Everett                                                 46800
       194 McCain                                                  38400
       195 Jones                                                   33600
       196 Walsh                                                   37200
       197 Feeney                                                  36000
       198 OConnell                                                31200

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       199 Grant                                                   31200

45 rows selected.

SQL> update employees
  2
SQL>
SQL> ed
Wrote file afiedt.buf

  1  update employees
  2  set salary =100000
  3* where employee_id =120
SQL> /

1 row updated.

SQL> select *from empsalvu50
  2  /

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       120 Weiss                                                   96000
       121 Fripp                                                   98400
       122 Kaufling                                                94800
       123 Vollman                                                 78000
       124 Mourgos                                                 69600
       125 Nayer                                                   38400
       126 Mikkilineni                                             32400
       127 Landry                                                  28800
       128 Markle                                                  26400
       129 Bissot                                                  39600
       130 Atkinson                                                33600

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       131 Marlow                                                  30000
       132 Olson                                                   25200
       133 Mallin                                                  39600
       134 Rogers                                                  34800
       135 Gee                                                     28800
       136 Philtanker                                              26400
       137 Ladwig                                                  43200
       138 Stiles                                                  38400
       139 Seo                                                     32400
       140 Patel                                                   30000
       141 Rajs                                                    42000

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       142 Davies                                                  37200
       143 Matos                                                   31200
       144 Vargas                                                  30000
       180 Taylor                                                  38400
       181 Fleaur                                                  37200
       182 Sullivan                                                30000
       183 Geoni                                                   33600
       184 Sarchand                                                50400
       185 Bull                                                    49200
       186 Dellinger                                               40800
       187 Cabrio                                                  36000

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       188 Chung                                                   45600
       189 Dilly                                                   43200
       190 Gates                                                   34800
       191 Perkins                                                 30000
       192 Bell                                                    48000
       193 Everett                                                 46800
       194 McCain                                                  38400
       195 Jones                                                   33600
       196 Walsh                                                   37200
       197 Feeney                                                  36000
       198 OConnell                                                31200

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       199 Grant                                                   31200

45 rows selected.

SQL>
SQL> select *from salvu50
  2  /

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       120 Weiss                                                 1200000
       121 Fripp                                                   98400
       122 Kaufling                                                94800
       123 Vollman                                                 78000
       124 Mourgos                                                 69600
       125 Nayer                                                   38400
       126 Mikkilineni                                             32400
       127 Landry                                                  28800
       128 Markle                                                  26400
       129 Bissot                                                  39600
       130 Atkinson                                                33600

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       131 Marlow                                                  30000
       132 Olson                                                   25200
       133 Mallin                                                  39600
       134 Rogers                                                  34800
       135 Gee                                                     28800
       136 Philtanker                                              26400
       137 Ladwig                                                  43200
       138 Stiles                                                  38400
       139 Seo                                                     32400
       140 Patel                                                   30000
       141 Rajs                                                    42000

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       142 Davies                                                  37200
       143 Matos                                                   31200
       144 Vargas                                                  30000
       180 Taylor                                                  38400
       181 Fleaur                                                  37200
       182 Sullivan                                                30000
       183 Geoni                                                   33600
       184 Sarchand                                                50400
       185 Bull                                                    49200
       186 Dellinger                                               40800
       187 Cabrio                                                  36000

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       188 Chung                                                   45600
       189 Dilly                                                   43200
       190 Gates                                                   34800
       191 Perkins                                                 30000
       192 Bell                                                    48000
       193 Everett                                                 46800
       194 McCain                                                  38400
       195 Jones                                                   33600
       196 Walsh                                                   37200
       197 Feeney                                                  36000
       198 OConnell                                                31200

 ID_NUMBER NAME                                               ANN_SALARY
---------- -------------------------------------------------- ----------
       199 Grant                                                   31200

45 rows selected.

SQL> rollback;

Rollback complete.

SQL> /

Rollback complete.

SQL> select *from salvu50 /
  2
SQL>
SQL>
SQL>
SQL> select rownum. salarry
  2  from employees
  3  /
select rownum. salarry
             *
ERROR at line 1:
ORA-00923: FROM keyword not found where expected


SQL> ed
Wrote file afiedt.buf

  1  select rownum, salarry
  2* from employees
SQL> /
select rownum, salarry
               *
ERROR at line 1:
ORA-00904: "SALARRY": invalid identifier


SQL> ed
Wrote file afiedt.buf

  1  select rownum, salary
  2* from employees
SQL> /

    ROWNUM     SALARY
---------- ----------
         1      24000
         2      17000
         3      17000
         4       9000
         5       6000
         6       4800
         7       4800
         8       4200
         9      12008
        10       9000
        11       8200

    ROWNUM     SALARY
---------- ----------
        12       7700
        13       7800
        14       6900
        15      11000
        16       3100
        17       2900
        18       2800
        19       2600
        20       2500
        21       8000
        22       8200

    ROWNUM     SALARY
---------- ----------
        23       7900
        24       6500
        25       5800
        26       3200
        27       2700
        28       2400
        29       2200
        30       3300
        31       2800
        32       2500
        33       2100

    ROWNUM     SALARY
---------- ----------
        34       3300
        35       2900
        36       2400
        37       2200
        38       3600
        39       3200
        40       2700
        41       2500
        42       3500
        43       3100
        44       2600

    ROWNUM     SALARY
---------- ----------
        45       2500
        46      14000
        47      13500
        48      12000
        49      11000
        50      10500
        51      10000
        52       9500
        53       9000
        54       8000
        55       7500

    ROWNUM     SALARY
---------- ----------
        56       7000
        57      10000
        58       9500
        59       9000
        60       8000
        61       7500
        62       7000
        63      10500
        64       9500
        65       7200
        66       6800

    ROWNUM     SALARY
---------- ----------
        67       6400
        68       6200
        69      11500
        70      10000
        71       9600
        72       7400
        73       7300
        74       6100
        75      11000
        76       8800
        77       8600

    ROWNUM     SALARY
---------- ----------
        78       8400
        79       7000
        80       6200
        81       3200
        82       3100
        83       2500
        84       2800
        85       4200
        86       4100
        87       3400
        88       3000

    ROWNUM     SALARY
---------- ----------
        89       3800
        90       3600
        91       2900
        92       2500
        93       4000
        94       3900
        95       3200
        96       2800
        97       3100
        98       3000
        99       2600

    ROWNUM     SALARY
---------- ----------
       100       2600
       101       4400
       102      13000
       103       6000
       104       6500
       105      10000
       106      12008
       107       8300

107 rows selected.

SQL> ed
Wrote file afiedt.buf

  1  select rownum, last_name, salary
  2  from employees
  3  where romnum <=3
  4* order by salary desc
SQL> /
where romnum <=3
      *
ERROR at line 3:
ORA-00904: "ROMNUM": invalid identifier


SQL> ed
Wrote file afiedt.buf

  1  select rownum, last_name, salary
  2  from employees
  3  where rownum <=3
  4* order by salary desc
SQL> /

    ROWNUM LAST_NAME                                              SALARY
---------- -------------------------------------------------- ----------
         1 King                                                    24000
         3 De Haan                                                 17000
         2 Kochhar                                                 17000

SQL> ed
Wrote file afiedt.buf

  1  select rownum, last_name, salary
  2  from employees
  3  where rownum <=5
  4* order by salary desc
SQL> /

    ROWNUM LAST_NAME                                              SALARY
---------- -------------------------------------------------- ----------
         1 King                                                    24000
         2 Kochhar                                                 17000
         3 De Haan                                                 17000
         4 Hunold                                                   9000
         5 Ernst                                                    6000

SQL> ed
Wrote file afiedt.buf

  1  select rownum, last_name, salary
  2  from employees
  3  having rownum <=5
  4* order by salary desc
SQL> /
select rownum, last_name, salary
       *
ERROR at line 1:
ORA-00979: not a GROUP BY expression


SQL> ed
Wrote file afiedt.buf

  1  select rownum, last_name, salary
  2  from (
  3     select rownum, last_name, salary
  4     from employees
  5     order by salary desc
  6  )
  7* where rownum <=5
SQL> ed
Wrote file afiedt.buf

  1  select rownum, last_name, salary
  2  from (
  3     select rownum, last_name, salary
  4     from employees
  5     order by salary desc
  6  )
  7* where rownum <=5
SQL> /

    ROWNUM LAST_NAME                                              SALARY
---------- -------------------------------------------------- ----------
         1 King                                                    24000
         2 Kochhar                                                 17000
         3 De Haan                                                 17000
         4 Russell                                                 14000
         5 Partners                                                13500

SQL> select a.last_name, a.salary, a.department_id, b.maxsal
  2  from employees a, (select departement_id, max(salary) maxsal
  3  from employees
  4  group by department_id) b
  5  a.department_id = b.department_id
  6  and
  7
SQL>
SQL> ed
Wrote file afiedt.buf

  1  select a.last_name, a.salary, a.department_id, b.maxsal
  2  from employees a, (select departement_id, max(salary) maxsal
  3  from employees
  4  group by department_id) b
  5  where a.department_id = b.department_id
  6* and a.salary < b.maxsal
SQL> /
from employees a, (select departement_id, max(salary) maxsal
                          *
ERROR at line 2:
ORA-00904: "DEPARTEMENT_ID": invalid identifier


SQL> ed
Wrote file afiedt.buf

  1  select a.last_name, a.salary, a.department_id, b.maxsal
  2  from employees a, (select department_id, max(salary) maxsal
  3  from employees
  4  group by department_id) b
  5  where a.department_id = b.department_id
  6* and a.salary < b.maxsal
SQL> /

LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Faviet                                                   9000           100
     12008

Chen                                                     8200           100
     12008

Sciarra                                                  7700           100
     12008


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Urman                                                    7800           100
     12008

Popp                                                     6900           100
     12008

Khoo                                                     3100            30
     11000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Baida                                                    2900            30
     11000

Tobias                                                   2800            30
     11000

Himuro                                                   2600            30
     11000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Colmenares                                               2500            30
     11000

Kochhar                                                 17000            90
     24000

De Haan                                                 17000            90
     24000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Fay                                                      6000            20
     13000

Gietz                                                    8300           110
     12008

Weiss                                                    8000            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Kaufling                                                 7900            50
      8200

Vollman                                                  6500            50
      8200

Mourgos                                                  5800            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Nayer                                                    3200            50
      8200

Mikkilineni                                              2700            50
      8200

Landry                                                   2400            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Markle                                                   2200            50
      8200

Bissot                                                   3300            50
      8200

Atkinson                                                 2800            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Marlow                                                   2500            50
      8200

Olson                                                    2100            50
      8200

Mallin                                                   3300            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Rogers                                                   2900            50
      8200

Gee                                                      2400            50
      8200

Philtanker                                               2200            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Ladwig                                                   3600            50
      8200

Stiles                                                   3200            50
      8200

Seo                                                      2700            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Patel                                                    2500            50
      8200

Rajs                                                     3500            50
      8200

Davies                                                   3100            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Matos                                                    2600            50
      8200

Vargas                                                   2500            50
      8200

Taylor                                                   3200            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Fleaur                                                   3100            50
      8200

Sullivan                                                 2500            50
      8200

Geoni                                                    2800            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Sarchand                                                 4200            50
      8200

Bull                                                     4100            50
      8200

Dellinger                                                3400            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Cabrio                                                   3000            50
      8200

Chung                                                    3800            50
      8200

Dilly                                                    3600            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Gates                                                    2900            50
      8200

Perkins                                                  2500            50
      8200

Bell                                                     4000            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Everett                                                  3900            50
      8200

McCain                                                   3200            50
      8200

Jones                                                    2800            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Walsh                                                    3100            50
      8200

Feeney                                                   3000            50
      8200

OConnell                                                 2600            50
      8200


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Grant                                                    2600            50
      8200

Partners                                                13500            80
     14000

Errazuriz                                               12000            80
     14000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Cambrault                                               11000            80
     14000

Zlotkey                                                 10500            80
     14000

Tucker                                                  10000            80
     14000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Bernstein                                                9500            80
     14000

Hall                                                     9000            80
     14000

Olsen                                                    8000            80
     14000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Cambrault                                                7500            80
     14000

Tuvault                                                  7000            80
     14000

King                                                    10000            80
     14000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Sully                                                    9500            80
     14000

McEwen                                                   9000            80
     14000

Smith                                                    8000            80
     14000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Doran                                                    7500            80
     14000

Sewall                                                   7000            80
     14000

Vishney                                                 10500            80
     14000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Greene                                                   9500            80
     14000

Marvins                                                  7200            80
     14000

Lee                                                      6800            80
     14000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Ande                                                     6400            80
     14000

Banda                                                    6200            80
     14000

Ozer                                                    11500            80
     14000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Bloom                                                   10000            80
     14000

Fox                                                      9600            80
     14000

Smith                                                    7400            80
     14000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Bates                                                    7300            80
     14000

Kumar                                                    6100            80
     14000

Abel                                                    11000            80
     14000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Hutton                                                   8800            80
     14000

Taylor                                                   8600            80
     14000

Livingston                                               8400            80
     14000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Johnson                                                  6200            80
     14000

Ernst                                                    6000            60
      9000

Austin                                                   4800            60
      9000


LAST_NAME                                              SALARY DEPARTMENT_ID
-------------------------------------------------- ---------- -------------
    MAXSAL
----------
Pataballa                                                4800            60
      9000

Lorentz                                                  4200            60
      9000


95 rows selected.

SQL>
SQL>
SQL> column last_name format a13
SQL> /

LAST_NAME         SALARY DEPARTMENT_ID     MAXSAL
------------- ---------- ------------- ----------
Faviet              9000           100      12008
Chen                8200           100      12008
Sciarra             7700           100      12008
Urman               7800           100      12008
Popp                6900           100      12008
Khoo                3100            30      11000
Baida               2900            30      11000
Tobias              2800            30      11000
Himuro              2600            30      11000
Colmenares          2500            30      11000
Kochhar            17000            90      24000

LAST_NAME         SALARY DEPARTMENT_ID     MAXSAL
------------- ---------- ------------- ----------
De Haan            17000            90      24000
Fay                 6000            20      13000
Gietz               8300           110      12008
Weiss               8000            50       8200
Kaufling            7900            50       8200
Vollman             6500            50       8200
Mourgos             5800            50       8200
Nayer               3200            50       8200
Mikkilineni         2700            50       8200
Landry              2400            50       8200
Markle              2200            50       8200

LAST_NAME         SALARY DEPARTMENT_ID     MAXSAL
------------- ---------- ------------- ----------
Bissot              3300            50       8200
Atkinson            2800            50       8200
Marlow              2500            50       8200
Olson               2100            50       8200
Mallin              3300            50       8200
Rogers              2900            50       8200
Gee                 2400            50       8200
Philtanker          2200            50       8200
Ladwig              3600            50       8200
Stiles              3200            50       8200
Seo                 2700            50       8200

LAST_NAME         SALARY DEPARTMENT_ID     MAXSAL
------------- ---------- ------------- ----------
Patel               2500            50       8200
Rajs                3500            50       8200
Davies              3100            50       8200
Matos               2600            50       8200
Vargas              2500            50       8200
Taylor              3200            50       8200
Fleaur              3100            50       8200
Sullivan            2500            50       8200
Geoni               2800            50       8200
Sarchand            4200            50       8200
Bull                4100            50       8200

LAST_NAME         SALARY DEPARTMENT_ID     MAXSAL
------------- ---------- ------------- ----------
Dellinger           3400            50       8200
Cabrio              3000            50       8200
Chung               3800            50       8200
Dilly               3600            50       8200
Gates               2900            50       8200
Perkins             2500            50       8200
Bell                4000            50       8200
Everett             3900            50       8200
McCain              3200            50       8200
Jones               2800            50       8200
Walsh               3100            50       8200

LAST_NAME         SALARY DEPARTMENT_ID     MAXSAL
------------- ---------- ------------- ----------
Feeney              3000            50       8200
OConnell            2600            50       8200
Grant               2600            50       8200
Partners           13500            80      14000
Errazuriz          12000            80      14000
Cambrault          11000            80      14000
Zlotkey            10500            80      14000
Tucker             10000            80      14000
Bernstein           9500            80      14000
Hall                9000            80      14000
Olsen               8000            80      14000

LAST_NAME         SALARY DEPARTMENT_ID     MAXSAL
------------- ---------- ------------- ----------
Cambrault           7500            80      14000
Tuvault             7000            80      14000
King               10000            80      14000
Sully               9500            80      14000
McEwen              9000            80      14000
Smith               8000            80      14000
Doran               7500            80      14000
Sewall              7000            80      14000
Vishney            10500            80      14000
Greene              9500            80      14000
Marvins             7200            80      14000

LAST_NAME         SALARY DEPARTMENT_ID     MAXSAL
------------- ---------- ------------- ----------
Lee                 6800            80      14000
Ande                6400            80      14000
Banda               6200            80      14000
Ozer               11500            80      14000
Bloom              10000            80      14000
Fox                 9600            80      14000
Smith               7400            80      14000
Bates               7300            80      14000
Kumar               6100            80      14000
Abel               11000            80      14000
Hutton              8800            80      14000

LAST_NAME         SALARY DEPARTMENT_ID     MAXSAL
------------- ---------- ------------- ----------
Taylor              8600            80      14000
Livingston          8400            80      14000
Johnson             6200            80      14000
Ernst               6000            60       9000
Austin              4800            60       9000
Pataballa           4800            60       9000
Lorentz             4200            60       9000

95 rows selected.

SQL>
SQL>
SQL>
SQL> select rownum as rank , last_nam, salary
  2  from (
  3     select last_name, salary
  4     from employees
  5     order by salary desc
  6  )
  7  where rownum <= 3 ;
select rownum as rank , last_nam, salary
                        *
ERROR at line 1:
ORA-00904: "LAST_NAM": invalid identifier


SQL> ed
Wrote file afiedt.buf

  1  select rownum as rank , last_name, salary
  2  from (
  3     select last_name, salary
  4     from employees
  5     order by salary desc
  6  )
  7* where rownum <= 3
SQL> /

      RANK LAST_NAME         SALARY
---------- ------------- ----------
         1 King               24000
         2 Kochhar            17000
         3 De Haan            17000

SQL> ed
Wrote file afiedt.buf

  1  select rownum as rank , last_name, salary
  2  from (
  3     select last_name, salary
  4     from employees
  5     order by salary desc
  6  )
  7* where rownum > 3
SQL> /

no rows selected

SQL>
SQL>
SQL> select rownum as rank, department_id, avg(salary)
  2  from
  3  (
  4     select department, avg(salary)
  5     from employees
  6     order by salary desc
  7  )
  8  where rownum <= 3
  9  /
        select department, avg(salary)
               *
ERROR at line 4:
ORA-00904: "DEPARTMENT": invalid identifier


SQL> ed
Wrote file afiedt.buf

  1  select rownum as rank, department_id, avg(salary)
  2  from
  3  (
  4     select department_id, avg(salary)
  5     from employees
  6     order by salary desc
  7  )
  8* where rownum <= 3
SQL> /
select rownum as rank, department_id, avg(salary)
                                          *
ERROR at line 1:
ORA-00904: "SALARY": invalid identifier


SQL> ed
Wrote file afiedt.buf

  1  select rownum as rank, department_id, avg(salary)
  2  from
  3  (
  4     select department_id, avg(salary)
  5     from employees
  6     order by salary desc
  7  )
  8* where rownum <= 3
SQL>
SQL>
SQL>
SQL> /
select rownum as rank, department_id, avg(salary)
                                          *
ERROR at line 1:
ORA-00904: "SALARY": invalid identifier


SQL> ed
Wrote file afiedt.buf

  1  select rownum as rank, department_id, salary
  2  from
  3  (
  4     select department_id, avg(salary)
  5     from employees
  6     order by salary desc
  7  )
  8* where rownum <= 3
SQL> /
select rownum as rank, department_id, salary
                                      *
ERROR at line 1:
ORA-00904: "SALARY": invalid identifier


SQL>
SQL> ed
Wrote file afiedt.buf

  1  select rownum as rank, department_id, AVG
  2  from
  3  (
  4     select department_id, avg(salary) AVG
  5     from employees
  6     group by department_id
  7     order by salary AVG desc
  8  )
  9* where rownum <= 3
SQL> /
        order by salary AVG desc
                        *
ERROR at line 7:
ORA-00907: missing right parenthesis


SQL> ed
Wrote file afiedt.buf

  1  select rownum as rank, department_id, AVG
  2  from
  3  (
  4     select department_id, avg(salary) AVG
  5     from employees
  6     group by department_id
  7     order by AVG desc
  8  )
  9* where rownum <= 3
SQL> /

      RANK DEPARTMENT_ID        AVG
---------- ------------- ----------
         1            90 19333.3333
         2           110      10154
         3            70      10000

SQL>
SQL>
SQL> create sequence dept_deptid seq
  2     increament by 10
  3  start with 300
  4     maxvalue 9999
  5     nocache
  6     nocycle
  7  ;
create sequence dept_deptid seq
                            *
ERROR at line 1:
ORA-00933: SQL command not properly ended


SQL> ed
Wrote file afiedt.buf

  1  create sequence dept_deptid seq
  2     increament by 10
  3     start with 300
  4     maxvalue 9999
  5     nocache
  6*    nocycle
  7  /
create sequence dept_deptid seq
                            *
ERROR at line 1:
ORA-00933: SQL command not properly ended


SQL> ed
Wrote file afiedt.buf

  1  create sequence dept_deptid seq
  2     increament by 10
  3     start with 300
  4*    maxvalue 9999
SQL> /
create sequence dept_deptid seq
                            *
ERROR at line 1:
ORA-00933: SQL command not properly ended


SQL> ed
Wrote file afiedt.buf

  1  create sequence dept_deptid_seq
  2     increament by 10
  3     start with 300
  4*    maxvalue 9999
SQL> /
        increament by 10
        *
ERROR at line 2:
ORA-00933: SQL command not properly ended


SQL>
SQL>
SQL>
SQL> ed
Wrote file afiedt.buf

  1  create sequence dept_deptid_seq
  2     increment by 10
  3     start with 300
  4*    maxvalue 9999
SQL> /

Sequence created.

SQL> select *from dept_deptid_seq
  2  /
select *from dept_deptid_seq
             *
ERROR at line 1:
ORA-02201: sequence not allowed here


SQL> ed
Wrote file afiedt.buf

  1  select sepyence_name, min_value, max_vale, increment_by,
  2  last_number
  3  from user_sepuences
  4* where sepuence_name = 'dept_deptid_seq'
SQL> /
from user_sepuences
     *
ERROR at line 3:
ORA-00942: table or view does not exist


SQL> ed
Wrote file afiedt.buf

  1  select sepyence_name, min_value, max_vale, increment_by,
  2  last_number
  3  from user_sequences
  4* where sepuence_name = 'dept_deptid_seq'
SQL> /
where sepuence_name = 'dept_deptid_seq'
      *
ERROR at line 4:
ORA-00904: "SEPUENCE_NAME": invalid identifier


SQL> ed
Wrote file afiedt.buf

  1  select sepyence_name, min_value, max_vale, increment_by,
  2  last_number
  3  from user_sequences
  4* where sequence_name = 'dept_deptid_seq'
SQL> /
select sepyence_name, min_value, max_vale, increment_by,
                                 *
ERROR at line 1:
ORA-00904: "MAX_VALE": invalid identifier


SQL> ed
Wrote file afiedt.buf

  1  select sepyence_name, min_value, max_value, increment_by,
  2  last_number
  3  from user_sequences
  4* where sequence_name = 'dept_deptid_seq'
SQL> /
select sepyence_name, min_value, max_value, increment_by,
       *
ERROR at line 1:
ORA-00904: "SEPYENCE_NAME": invalid identifier


SQL> ed
Wrote file afiedt.buf

  1  select sequence_name, min_value, max_value, increment_by,
  2  last_number
  3  from user_sequences
  4* where sequence_name = 'dept_deptid_seq'
SQL> /

no rows selected

SQL> ed
Wrote file afiedt.buf

  1  select sequence_name, min_value, max_value, increment_by,
  2  last_number
  3  from user_sequences
  4* where sequence_name = 'dept_deptid_seq'
SQL> /

no rows selected

SQL> ;
  1  select sequence_name, min_value, max_value, increment_by,
  2  last_number
  3  from user_sequences
  4* where sequence_name = 'dept_deptid_seq'
SQL> ;
  1  select sequence_name, min_value, max_value, increment_by,
  2  last_number
  3  from user_sequences
  4* where sequence_name = 'dept_deptid_seq'
SQL> /

no rows selected

SQL> create sequence dept_deptid_seq
  2  increment by 10
  3  start with 300
  4  maxvalue 9999
  5  /
create sequence dept_deptid_seq
                *
ERROR at line 1:
ORA-00955: name is already used by an existing object


SQL> ed
Wrote file afiedt.buf

  1  create sequence dept_deptid_seq
  2  increment by 10
  3  start with 300
  4* maxvalue 9999
SQL> /
create sequence dept_deptid_seq
                *
ERROR at line 1:
ORA-00955: name is already used by an existing object


SQL>
SQL>
SQL>
SQL>
SQL> select sequence_name, min_value, max_value, increment_by,
  2  last_number
  3  from user_sequences
  4  where sequence_name = 'dept_deptid_seq'
  5  /

no rows selected

SQL>
SQL> select sequence_name, min_value, max_value, increment_by,
  2  last_number
  3  from user_sequences
  4  /

SEQUENCE_NAME                                                 MIN_VALUE
------------------------------------------------------------ ----------
 MAX_VALUE INCREMENT_BY LAST_NUMBER
---------- ------------ -----------
DEPARTMENTS_SEQ                                                       1
      9990           10         280

DEPT_DEPTID_SEQ                                                       1
      9999           10         300

EMPLOYEES_SEQ                                                         1
1.0000E+28            1         207


SEQUENCE_NAME                                                 MIN_VALUE
------------------------------------------------------------ ----------
 MAX_VALUE INCREMENT_BY LAST_NUMBER
---------- ------------ -----------
LOCATIONS_SEQ                                                         1
      9900          100        3300


SQL>
SQL> select sequence_name, min_value, max_value, increment_by,
  2  last_number
  3  from user_sequences
  4  where sequence_name = 'dept_deptid_seq'
  5  /

no rows selected

SQL>
SQL>
SQL>
SQL> select *from department
  2  /
select *from department
             *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> ed
Wrote file afiedt.buf

  1* select *from departments
SQL> /

DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
           10 Administration
       200        1700

           20 Marketing
       201        1800

           30 Purchasing
       114        1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
           40 Human Resources
       203        2400

           50 Shipping
       121        1500

           60 IT
       103        1400


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
           70 Public Relations
       204        2700

           80 Sales
       145        2500

           90 Executive
       100        1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          100 Finance
       108        1700

          110 Accounting
       205        1700

          120 Treasury
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          130 Corporate Tax
                  1700

          140 Control And Credit
                  1700

          150 Shareholder Services
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          160 Benefits
                  1700

          170 Manufacturing
                  1700

          180 Construction
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          190 Contracting
                  1700

          200 Operations
                  1700

          210 IT Support
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          220 NOC
                  1700

          230 IT Helpdesk
                  1700

          240 Government Sales
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          250 Retail Sales
                  1700

          260 Recruiting
                  1700

          270 Payroll
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          280 test
       100        1700

          290 test1



29 rows selected.

SQL> column deaprtment_name format a18
SQL> /

DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
           10 Administration
       200        1700

           20 Marketing
       201        1800

           30 Purchasing
       114        1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
           40 Human Resources
       203        2400

           50 Shipping
       121        1500

           60 IT
       103        1400


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
           70 Public Relations
       204        2700

           80 Sales
       145        2500

           90 Executive
       100        1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          100 Finance
       108        1700

          110 Accounting
       205        1700

          120 Treasury
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          130 Corporate Tax
                  1700

          140 Control And Credit
                  1700

          150 Shareholder Services
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          160 Benefits
                  1700

          170 Manufacturing
                  1700

          180 Construction
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          190 Contracting
                  1700

          200 Operations
                  1700

          210 IT Support
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          220 NOC
                  1700

          230 IT Helpdesk
                  1700

          240 Government Sales
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          250 Retail Sales
                  1700

          260 Recruiting
                  1700

          270 Payroll
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          280 test
       100        1700

          290 test1



29 rows selected.

SQL> column deaprtment_name format a15
SQL> /

DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
           10 Administration
       200        1700

           20 Marketing
       201        1800

           30 Purchasing
       114        1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
           40 Human Resources
       203        2400

           50 Shipping
       121        1500

           60 IT
       103        1400


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
           70 Public Relations
       204        2700

           80 Sales
       145        2500

           90 Executive
       100        1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          100 Finance
       108        1700

          110 Accounting
       205        1700

          120 Treasury
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          130 Corporate Tax
                  1700

          140 Control And Credit
                  1700

          150 Shareholder Services
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          160 Benefits
                  1700

          170 Manufacturing
                  1700

          180 Construction
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          190 Contracting
                  1700

          200 Operations
                  1700

          210 IT Support
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          220 NOC
                  1700

          230 IT Helpdesk
                  1700

          240 Government Sales
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          250 Retail Sales
                  1700

          260 Recruiting
                  1700

          270 Payroll
                  1700


DEPARTMENT_ID DEPARTMENT_NAME
------------- ------------------------------------------------------------
MANAGER_ID LOCATION_ID
---------- -----------
          280 test
       100        1700

          290 test1



29 rows selected.

SQL> column department_name format a15
SQL> /

DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
------------- --------------- ---------- -----------
           10 Administration         200        1700
           20 Marketing              201        1800
           30 Purchasing             114        1700
           40 Human Resources        203        2400
           50 Shipping               121        1500
           60 IT                     103        1400
           70 Public Relation        204        2700
              s

           80 Sales                  145        2500
           90 Executive              100        1700

DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
------------- --------------- ---------- -----------
          100 Finance                108        1700
          110 Accounting             205        1700
          120 Treasury                          1700
          130 Corporate Tax                     1700
          140 Control And Cre                   1700
              dit

          150 Shareholder Ser                   1700
              vices

          160 Benefits                          1700

DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
------------- --------------- ---------- -----------
          170 Manufacturing                     1700
          180 Construction                      1700
          190 Contracting                       1700
          200 Operations                        1700
          210 IT Support                        1700
          220 NOC                               1700
          230 IT Helpdesk                       1700
          240 Government Sale                   1700
              s

          250 Retail Sales                      1700

DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
------------- --------------- ---------- -----------
          260 Recruiting                        1700
          270 Payroll                           1700
          280 test                   100        1700
          290 test1

29 rows selected.

SQL> column department_name format a18
SQL> /

DEPARTMENT_ID DEPARTMENT_NAME    MANAGER_ID LOCATION_ID
------------- ------------------ ---------- -----------
           10 Administration            200        1700
           20 Marketing                 201        1800
           30 Purchasing                114        1700
           40 Human Resources           203        2400
           50 Shipping                  121        1500
           60 IT                        103        1400
           70 Public Relations          204        2700
           80 Sales                     145        2500
           90 Executive                 100        1700
          100 Finance                   108        1700
          110 Accounting                205        1700

DEPARTMENT_ID DEPARTMENT_NAME    MANAGER_ID LOCATION_ID
------------- ------------------ ---------- -----------
          120 Treasury                             1700
          130 Corporate Tax                        1700
          140 Control And Credit                   1700
          150 Shareholder Servic                   1700
              es

          160 Benefits                             1700
          170 Manufacturing                        1700
          180 Construction                         1700
          190 Contracting                          1700
          200 Operations                           1700

DEPARTMENT_ID DEPARTMENT_NAME    MANAGER_ID LOCATION_ID
------------- ------------------ ---------- -----------
          210 IT Support                           1700
          220 NOC                                  1700
          230 IT Helpdesk                          1700
          240 Government Sales                     1700
          250 Retail Sales                         1700
          260 Recruiting                           1700
          270 Payroll                              1700
          280 test                      100        1700
          290 test1

29 rows selected.

SQL> insert
  2
SQL>
SQL>
SQL> ed
Wrote file afiedt.buf

  1  insert into departments(
  2     empartment_id, department_name, locarion_id)
  3  value (
  4*    dept_deptid_seq.nextval, 'support', 2500)
SQL> /
value (
*
ERROR at line 3:
ORA-00926: missing VALUES keyword


SQL>
SQL>
SQL> ed
Wrote file afiedt.buf

  1  insert into departments(
  2     empartment_id, department_name, locarion_id)
  3  value (
  4*    dept_deptid_seq.nextval, 'Support', 2500)
SQL> /
value (
*
ERROR at line 3:
ORA-00926: missing VALUES keyword


SQL> ed
Wrote file afiedt.buf

  1  insert into departments(
  2     empartment_id, department_name, locarion_id)
  3  values (
  4*    dept_deptid_seq.nextval, 'Support', 2500)
SQL> /
        empartment_id, department_name, locarion_id)
                                        *
ERROR at line 2:
ORA-00904: "LOCARION_ID": invalid identifier


SQL> ed
Wrote file afiedt.buf

  1  insert into departments(
  2     empartment_id, department_name, location_id)
  3  values (
  4*    dept_deptid_seq.nextval, 'Support', 2500)
SQL> /
        empartment_id, department_name, location_id)
        *
ERROR at line 2:
ORA-00904: "EMPARTMENT_ID": invalid identifier


SQL> ed
Wrote file afiedt.buf

  1  insert into departments(
  2     department_id, department_name, location_id)
  3  values (
  4*    dept_deptid_seq.nextval, 'Support', 2500)
SQL> /

1 row created.

SQL> ed
Wrote file afiedt.buf

  1  insert into departments(
  2     department_id, department_name, location_id)
  3  values (
  4*    dept_deptid_seq.nextval, 'Support', 2500)
SQL> /

1 row created.

SQL>
SQL>
SQL> select *from departments
  2  /

DEPARTMENT_ID DEPARTMENT_NAME    MANAGER_ID LOCATION_ID
------------- ------------------ ---------- -----------
           10 Administration            200        1700
           20 Marketing                 201        1800
           30 Purchasing                114        1700
           40 Human Resources           203        2400
           50 Shipping                  121        1500
           60 IT                        103        1400
           70 Public Relations          204        2700
           80 Sales                     145        2500
           90 Executive                 100        1700
          100 Finance                   108        1700
          110 Accounting                205        1700

DEPARTMENT_ID DEPARTMENT_NAME    MANAGER_ID LOCATION_ID
------------- ------------------ ---------- -----------
          120 Treasury                             1700
          130 Corporate Tax                        1700
          140 Control And Credit                   1700
          150 Shareholder Servic                   1700
              es

          160 Benefits                             1700
          170 Manufacturing                        1700
          180 Construction                         1700
          190 Contracting                          1700
          200 Operations                           1700

DEPARTMENT_ID DEPARTMENT_NAME    MANAGER_ID LOCATION_ID
------------- ------------------ ---------- -----------
          210 IT Support                           1700
          220 NOC                                  1700
          230 IT Helpdesk                          1700
          240 Government Sales                     1700
          250 Retail Sales                         1700
          260 Recruiting                           1700
          270 Payroll                              1700
          280 test                      100        1700
          290 test1
          300 Support                              2500
          310 Support                              2500

31 rows selected.

SQL> rollback
  2  /

Rollback complete.

SQL>
SQL> select *from departments
  2
SQL> /

DEPARTMENT_ID DEPARTMENT_NAME    MANAGER_ID LOCATION_ID
------------- ------------------ ---------- -----------
           10 Administration            200        1700
           20 Marketing                 201        1800
           30 Purchasing                114        1700
           40 Human Resources           203        2400
           50 Shipping                  121        1500
           60 IT                        103        1400
           70 Public Relations          204        2700
           80 Sales                     145        2500
           90 Executive                 100        1700
          100 Finance                   108        1700
          110 Accounting                205        1700

DEPARTMENT_ID DEPARTMENT_NAME    MANAGER_ID LOCATION_ID
------------- ------------------ ---------- -----------
          120 Treasury                             1700
          130 Corporate Tax                        1700
          140 Control And Credit                   1700
          150 Shareholder Servic                   1700
              es

          160 Benefits                             1700
          170 Manufacturing                        1700
          180 Construction                         1700
          190 Contracting                          1700
          200 Operations                           1700

DEPARTMENT_ID DEPARTMENT_NAME    MANAGER_ID LOCATION_ID
------------- ------------------ ---------- -----------
          210 IT Support                           1700
          220 NOC                                  1700
          230 IT Helpdesk                          1700
          240 Government Sales                     1700
          250 Retail Sales                         1700
          260 Recruiting                           1700
          270 Payroll                              1700
          280 test                      100        1700
          290 test1

29 rows selected.

SQL> insert into departments(
  2  department_id, department_name, location_id )
  3  values (
  4  dept_deptid_seq.nextval, 'Support', 2500 )
  5  /

1 row created.

SQL> select *from departments
  2  /

DEPARTMENT_ID DEPARTMENT_NAME    MANAGER_ID LOCATION_ID
------------- ------------------ ---------- -----------
           10 Administration            200        1700
           20 Marketing                 201        1800
           30 Purchasing                114        1700
           40 Human Resources           203        2400
           50 Shipping                  121        1500
           60 IT                        103        1400
           70 Public Relations          204        2700
           80 Sales                     145        2500
           90 Executive                 100        1700
          100 Finance                   108        1700
          110 Accounting                205        1700

DEPARTMENT_ID DEPARTMENT_NAME    MANAGER_ID LOCATION_ID
------------- ------------------ ---------- -----------
          120 Treasury                             1700
          130 Corporate Tax                        1700
          140 Control And Credit                   1700
          150 Shareholder Servic                   1700
              es

          160 Benefits                             1700
          170 Manufacturing                        1700
          180 Construction                         1700
          190 Contracting                          1700
          200 Operations                           1700

DEPARTMENT_ID DEPARTMENT_NAME    MANAGER_ID LOCATION_ID
------------- ------------------ ---------- -----------
          210 IT Support                           1700
          220 NOC                                  1700
          230 IT Helpdesk                          1700
          240 Government Sales                     1700
          250 Retail Sales                         1700
          260 Recruiting                           1700
          270 Payroll                              1700
          280 test                      100        1700
          290 test1
          320 Support                              2500

30 rows selected.

SQL> select sequence_name, min_value, max_value, increment_by, last_number
  2  from user_sequences
  3  where sequence_name = 'dept_deptid_seq'
  4  /

no rows selected

SQL>
SQL>
SQL> select dept_deptid_seq.currval
  2  from dual
  3  ;

   CURRVAL
----------
       320

SQL> conn test/tset
ERROR:
ORA-01017: invalid username/password; logon denied


Warning: You are no longer connected to ORACLE.
SQL> conn test/tset
ERROR:
ORA-01017: invalid username/password; logon denied


SQL>
SQL>
SQL>
SQL> conn test/tset
ERROR:
ORA-01017: invalid username/password; logon denied


SQL>
SQL>
SQL> conn test/tset
ERROR:
ORA-01017: invalid username/password; logon denied


SQL> conn test/tset
ERROR:
ORA-01017: invalid username/password; logon denied


SQL>
SQL>
SQL> conn test/tset ;
ERROR:
ORA-01017: invalid username/password; logon denied


SQL> conn test/tset ;
ERROR:
ORA-01017: invalid username/password; logon denied


SQL>
SQL>
SQL>
SQL> conn test/test
Connected.
SQL>
SQL>
SQL>

____________



SQL*Plus: Release 11.2.0.2.0 Production on 월 6월 24 12:21:03 2019

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

SQL> conn sysem/12345
ERROR:
ORA-01017: invalid username/password; logon denied


SQL> conn system/12345
Connected.
SQL>
SQL> create user test
  2  identified by test
  3  ;

User created.

SQL> grant creat session to test
  2  /
grant creat session to test
      *
ERROR at line 1:
ORA-00990: missing or invalid privilege


SQL> ed
Wrote file afiedt.buf

  1* grant create session to test
SQL> /

Grant succeeded.

SQL> ed
Wrote file afiedt.buf

  1* grant create session to test
SQL>
SQL>
SQL>
SQL> /

Grant succeeded.

SQL>
SQL>
SQL>
SQL> ed
Wrote file afiedt.buf

  1* grant create session to test
SQL> /

Grant succeeded.

SQL>
SQL>
SQL> grant resource to test;

Grant succeeded.

SQL>

관련글 더보기

댓글 영역