Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.81 KB | None | 0 0
  1.  
  2. SQL*Plus: Release 10.2.0.1.0 - Production on Tue Feb 19 10:32:52 2019
  3.  
  4. Copyright (c) 1982, 2005, Oracle. All rights reserved.
  5.  
  6. SQL> create user parish identified by parish;
  7. SP2-0640: Not connected
  8. SQL> grant dba
  9. 2 grant dba;
  10. SP2-0640: Not connected
  11. SQL> connect sys as sysdba;
  12. Enter password:
  13. Connected.
  14. SQL> create table emp(empid int, ename varchar(50), title varchar(50), salary do
  15. uble, deptno int, mgrname varchar(50));
  16. create table emp(empid int, ename varchar(50), title varchar(50), salary double,
  17. deptno int, mgrname varchar(50))
  18. *
  19.  
  20. ERROR at line 1:
  21. ORA-00905: missing keyword
  22.  
  23.  
  24. SQL> create table emp(empid number(10), ename varchar2(50), title varchar2(50),
  25. salary number(50), deptno number(10), mgrname varchar2(50));
  26. create table emp(empid number(10), ename varchar2(50), title varchar2(50), salar
  27. y number(50), deptno number(10), mgrname varchar2(50))
  28.  
  29. *
  30. ERROR at line 1:
  31. ORA-01727: numeric precision specifier is out of range (1 to 38)
  32.  
  33.  
  34. SQL> create table emp(empid number(10), ename varchar2(50), title varchar2(50),
  35. salary number(10), deptno number(10), mgrname varchar2(50));
  36.  
  37. Table created.
  38.  
  39. SQL> insert into emp values(1,'Sabin','CSIT',500,7,'Parish');
  40.  
  41. 1 row created.
  42.  
  43. SQL> select *from emp
  44. 2 select *from emp;
  45. select *from emp
  46. *
  47. ERROR at line 2:
  48. ORA-00933: SQL command not properly ended
  49.  
  50.  
  51. SQL> select *from emp where empid=1;
  52.  
  53. EMPID ENAME
  54. ---------- --------------------------------------------------
  55. TITLE SALARY DEPTNO
  56. -------------------------------------------------- ---------- ----------
  57. MGRNAME
  58. --------------------------------------------------
  59. 1 Sabin
  60. CSIT 500 7
  61. Parish
  62.  
  63.  
  64. SQL> insert into emp values(2,'Rajnish','CSIT',500,7,'Parish');
  65.  
  66. 1 row created.
  67.  
  68. SQL> insert into emp values(3,'Subodh','CSIT',800,7,'Parish');
  69.  
  70. 1 row created.
  71.  
  72. SQL> insert into emp values(4,'Pemba','CSIT',100,7,'Parish');
  73.  
  74. 1 row created.
  75.  
  76. SQL> insert into emp values(5,'Rabindra','CSIT',50,7,'Parish');
  77.  
  78. 1 row created.
  79.  
  80. SQL> commit;
  81.  
  82. Commit complete.
  83.  
  84. SQL> select ename,salary*12,&sabin from emp;
  85. Enter value for sabin: rajnish
  86. old 1: select ename,salary*12,&sabin from emp
  87. new 1: select ename,salary*12,rajnish from emp
  88. select ename,salary*12,rajnish from emp
  89. *
  90. ERROR at line 1:
  91. ORA-00904: "RAJNISH": invalid identifier
  92.  
  93.  
  94. SQL> select ename,salary*12,&sabin from emp;
  95. Enter value for sabin: deptno
  96. old 1: select ename,salary*12,&sabin from emp
  97. new 1: select ename,salary*12,deptno from emp
  98.  
  99. ENAME SALARY*12 DEPTNO
  100. -------------------------------------------------- ---------- ----------
  101. Sabin 6000 7
  102. Rajnish 6000 7
  103. Subodh 9600 7
  104. Pemba 1200 7
  105. Rabindra 600 7
  106.  
  107. SQL> select ename, &ram from emp where empid<3;
  108. Enter value for ram: mgrname
  109. old 1: select ename, &ram from emp where empid<3
  110. new 1: select ename, mgrname from emp where empid<3
  111.  
  112. ENAME
  113. --------------------------------------------------
  114. MGRNAME
  115. --------------------------------------------------
  116. Sabin
  117. Parish
  118.  
  119. Rajnish
  120. Parish
  121.  
  122.  
  123. SQL> select ename, &ram from emp where &condition;
  124. Enter value for ram: salary
  125. Enter value for condition: ename=Sabin
  126. old 1: select ename, &ram from emp where &condition
  127. new 1: select ename, salary from emp where ename=Sabin
  128. select ename, salary from emp where ename=Sabin
  129. *
  130. ERROR at line 1:
  131. ORA-00904: "SABIN": invalid identifier
  132.  
  133.  
  134. SQL> select ename, &ram from emp where &condition;
  135. Enter value for ram: mgrname
  136. Enter value for condition: ename='Sabin'
  137. old 1: select ename, &ram from emp where &condition
  138. new 1: select ename, mgrname from emp where ename='Sabin'
  139.  
  140. ENAME
  141. --------------------------------------------------
  142. MGRNAME
  143. --------------------------------------------------
  144. Sabin
  145. Parish
  146.  
  147.  
  148. SQL> select ename, salary from emp where &condition;
  149. Enter value for condition: deptno=7
  150. old 1: select ename, salary from emp where &condition
  151. new 1: select ename, salary from emp where deptno=7
  152.  
  153. ENAME SALARY
  154. -------------------------------------------------- ----------
  155. Sabin 500
  156. Rajnish 500
  157. Subodh 800
  158. Pemba 100
  159. Rabindra 50
  160.  
  161. SQL> select ename, salary, &&condition from emp where &condition;
  162. Enter value for condition: empid=2
  163. old 1: select ename, salary, &&condition from emp where &condition
  164. new 1: select ename, salary, empid=2 from emp where empid=2
  165. select ename, salary, empid=2 from emp where empid=2
  166. *
  167. ERROR at line 1:
  168. ORA-00923: FROM keyword not found where expected
  169.  
  170.  
  171. SQL> select ename, salary, &&sanget from emp order by &sanget;
  172. Enter value for sanget: empid
  173. old 1: select ename, salary, &&sanget from emp order by &sanget
  174. new 1: select ename, salary, empid from emp order by empid
  175.  
  176. ENAME SALARY EMPID
  177. -------------------------------------------------- ---------- ----------
  178. Sabin 500 1
  179. Rajnish 500 2
  180. Subodh 800 3
  181. Pemba 100 4
  182. Rabindra 50 5
  183.  
  184. SQL> select ename, salary, &&sanget from emp order by &sanget;
  185. old 1: select ename, salary, &&sanget from emp order by &sanget
  186. new 1: select ename, salary, empid from emp order by empid
  187.  
  188. ENAME SALARY EMPID
  189. -------------------------------------------------- ---------- ----------
  190. Sabin 500 1
  191. Rajnish 500 2
  192. Subodh 800 3
  193. Pemba 100 4
  194. Rabindra 50 5
  195.  
  196. SQL> select ename, salary, &&sanget from emp order by &sanget;
  197. old 1: select ename, salary, &&sanget from emp order by &sanget
  198. new 1: select ename, salary, empid from emp order by empid
  199.  
  200. ENAME SALARY EMPID
  201. -------------------------------------------------- ---------- ----------
  202. Sabin 500 1
  203. Rajnish 500 2
  204. Subodh 800 3
  205. Pemba 100 4
  206. Rabindra 50 5
  207.  
  208. SQL> select ename, salary, &&sang from emp order by &sang;
  209. Enter value for sang: salary
  210. old 1: select ename, salary, &&sang from emp order by &sang
  211. new 1: select ename, salary, salary from emp order by salary
  212. select ename, salary, salary from emp order by salary
  213. *
  214. ERROR at line 1:
  215. ORA-00960: ambiguous column naming in select list
  216.  
  217.  
  218. SQL>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement