0% found this document useful (0 votes)
13 views

SQL conn

The document is a transcript of SQL commands executed in a database session, showcasing various SQL operations such as connecting to the database, describing tables, and performing queries on employee data. It includes examples of string manipulation, mathematical functions, date functions, and error messages encountered during the session. The commands demonstrate the use of SQL for data retrieval and manipulation, highlighting both successful executions and syntax errors.

Uploaded by

jipaxi1217
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

SQL conn

The document is a transcript of SQL commands executed in a database session, showcasing various SQL operations such as connecting to the database, describing tables, and performing queries on employee data. It includes examples of string manipulation, mathematical functions, date functions, and error messages encountered during the session. The commands demonstrate the use of SQL for data retrieval and manipulation, highlighting both successful executions and syntax errors.

Uploaded by

jipaxi1217
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 12

SQL> conn

Enter user-name: akshit2704


Enter password:
Connected.
SQL> ls
SP2-0042: unknown command "ls" - rest of line ignored.
SQL> desc employees
Name Null? Type
----------------------------------------- -------- ----------------------------
EMP_ID NUMBER(2)
NAME VARCHAR2(10)
JOB_TITLE VARCHAR2(40)
DEP_ID NUMBER(3)
SALARY NUMBER(6)

SQL> desc employee


Name Null? Type
----------------------------------------- -------- ----------------------------
EMPNO NUMBER(5)
NAME VARCHAR2(10)
JOB VARCHAR2(10)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(4)
COMM NUMBER(4)
DEPTNO NUMBER(2)

SQL> ls
SP2-0042: unknown command "ls" - rest of line ignored.
SQL> desc
Usage: DESCRIBE [schema.]object[@db_link]
SQL> select * from dual;

D
-
X

SQL> select upper('ram') from dual;

UPP
---
RAM

SQL> select concat('ram',' shyam')from dual;

CONCAT('R
---------
ram shyam

SQL> select concat ('ram',' shyam')from dual;

CONCAT('R
---------
ram shyam

SQL> select length ('ram shyam')from dual;

LENGTH('RAMSHYAM')
------------------
9

SQL> select length ('ram shyam') as len from dual;

LEN
----------
9

SQL> select lpac


2 ;

*
ERROR at line 2:
ORA-00923: FROM keyword not found where expected

SQL> select lpad('ram kumar',10,'*') as new from dual;

NEW
----------
*ram kumar

SQL> select lpad('ram kumar','10','*') as new from dual;

NEW
----------
*ram kumar

SQL> select lpad('ram kumar','10') as new from dual;

NEW
----------
ram kumar

SQL> select lpad('ram kumar','*') as new from dual;


select lpad('ram kumar','*') as new from dual
*
ERROR at line 1:
ORA-01722: invalid number

SQL> select translate('Ram','am',1);


select translate('Ram','am',1)
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

SQL> select translate('Ram','am',1) from dual;

TR
--
R1

SQL> select substr('chjsgzhjj',1,10) from dual;

SUBSTR('C
---------
chjsgzhjj
SQL> select instr('chjsgzhjj','g',1) from dual;

INSTR('CHJSGZHJJ','G',1)
------------------------
5

SQL> select reverse('chjsgzhjj') from dual;

REVERSE('
---------
jjhzgsjhc

SQL> select abs(-3,23),abs(34) as name from dual


2 ;
select abs(-3,23),abs(34) as name from dual
*
ERROR at line 1:
ORA-00909: invalid number of arguments

SQL> select abs(-3.23),abs(34) as name from dual;

ABS(-3.23) NAME
---------- ----------
3.23 34

SQL> select ciel(-3.23),abs(34) as name from dual;


select ciel(-3.23),abs(34) as name from dual
*
ERROR at line 1:
ORA-00904: "CIEL": invalid identifier

SQL> select ceil(-3.23),abs(34) as name from dual;

CEIL(-3.23) NAME
----------- ----------
-3 34

SQL> select round(-3.23),abs(34) as name from dual;

ROUND(-3.23) NAME
------------ ----------
-3 34

SQL> select round(-3.5),abs(34) as name from dual;

ROUND(-3.5) NAME
----------- ----------
-4 34

SQL> select round(-3,2),abs(34) as name from dual;

ROUND(-3,2) NAME
----------- ----------
-3 34

SQL> select power(-3,2),abs(34) as name from dual;


POWER(-3,2) NAME
----------- ----------
9 34

SQL> select power(-3,3),abs(34) as name from dual;

POWER(-3,3) NAME
----------- ----------
-27 34

SQL> select log(4,2),log(3,2) from dual;

LOG(4,2) LOG(3,2)
---------- ----------
.5 .630929754

SQL> select exp(2),exp(10) from dual;

EXP(2) EXP(10)
---------- ----------
7.3890561 22026.4658

SQL> select exp(2),exp(-2) from dual;

EXP(2) EXP(-2)
---------- ----------
7.3890561 .135335283

SQL> select trunc(5.6789,2) from dual;

TRUNC(5.6789,2)
---------------
5.67

SQL> select sin(30),cos(60),tan(90) from dual;

SIN(30) COS(60) TAN(90)


---------- ---------- ----------
-.98803162 -.95241298 -1.9952004

SQL> select sysdate as name from dual;

NAME
---------
10-FEB-25

SQL> select add_months(current_date,2) from dual;

ADD_MONTH
---------
10-APR-25

SQL> select add_months(current_date,-2) from dual;

ADD_MONTH
---------
10-DEC-24
SQL> select next_day(current_day frpom sunday) from dual;
select next_day(current_day frpom sunday) from dual
*
ERROR at line 1:
ORA-00909: invalid number of arguments

SQL> select next_day(current_day from sunday) from dual;


select next_day(current_day from sunday) from dual
*
ERROR at line 1:
ORA-00909: invalid number of arguments

SQL> select next_day(current_day, 'sunday') from dual;


select next_day(current_day, 'sunday') from dual
*
ERROR at line 1:
ORA-00904: "CURRENT_DAY": invalid identifier

SQL> select next_day(current_date,'sunday') from dual;

NEXT_DAY(
---------
16-FEB-25

SQL> select months_between(current_date,'12-feb-2000') from dual;

MONTHS_BETWEEN(CURRENT_DATE,'12-FEB-2000')
------------------------------------------
299.958735

SQL> select to_char('23')as afrom dual;


select to_char('23')as afrom dual
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

SQL> select to_char('23')as af rom dual;


select to_char('23')as af rom dual
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

SQL> select to_char('23')as a from dual;

A
--
23

SQL> select to_char('23','$000')as a from dual;

A
-----
$023
SQL> select to_char(sysdate,'ddth-mon-yy')as a from dual;

A
--------------------
10th-feb-25

SQL> select to_char(sysdate,'ddsp-mon-yy')as a from dual;

A
----------------------------
ten-feb-25

SQL> select to_char(sysdate,'ddthsp-mon-yy')as a from dual;

A
------------------------------
tenth-feb-25

SQL> select to_date('January 7,1998','month dd,yy')as a from dual;

A
---------
07-JAN-98

SQL> select nvl(null,'fallback')as a from dual;

A
--------
fallback

SQL> select nvl2(null,'yes','no')as a from dual;

A
--
no

SQL> select upper(name)from employees;

UPPER(NAME
----------
ALICE
BOB
CHARLIE
DAVID
EVE
FRANK
GRACE
HANK
IVY
JAKE

10 rows selected.

SQL> select lower(name)from employees;

LOWER(NAME
----------
alice
bob
charlie
david
eve
frank
grace
hank
ivy
jake

10 rows selected.

SQL> select substr(name,1,3)from employees;

SUBSTR(NAME,
------------
Ali
Bob
Cha
Dav
Eve
Fra
Gra
Han
Ivy
Jak

10 rows selected.

SQL> select RIGHT(name,3)from employees;


select RIGHT(name,3)from employees
*
ERROR at line 1:
ORA-00904: "RIGHT": invalid identifier

SQL> select substr((select length(name)-3),(select length(name))from employees;


select substr((select length(name)-3),(select length(name))from employees
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

SQL> select substr((select length(name) - 3 from employees ),(select length(name)


from employees)from employees;
select substr((select length(name) - 3 from employees ),(select length(name) from
employees)from employees

*
ERROR at line 1:
ORA-00907: missing right parenthesis

SQL> select substr(name,(length(name)-3),length(name))from employees;

SUBSTR(NAME,(LENGTH(NAME)-3),LENGTH(NAME
----------------------------------------
lice
Bob
rlie
avid
Eve
rank
race
Hank
Ivy
Jake

10 rows selected.

SQL> select substr(name,(length(name)-2),length(name))from employees;

SUBSTR(NAME,(LENGTH(NAME)-2),LENGTH(NAME
----------------------------------------
ice
Bob
lie
vid
Eve
ank
ace
ank
Ivy
ake

10 rows selected.

SQL> select trim(' ' from names)from employees;


select trim(' ' from names)from employees
*
ERROR at line 1:
ORA-00904: "NAMES": invalid identifier

SQL> select trim(' ' from name)from employees;

TRIM(''FRO
----------
Alice
Bob
Charlie
David
Eve
Frank
Grace
Hank
Ivy
Jake

10 rows selected.

SQL> desc employees


Name Null? Type
----------------------------------------- -------- ----------------------------
EMP_ID NUMBER(2)
NAME VARCHAR2(10)
JOB_TITLE VARCHAR2(40)
DEP_ID NUMBER(3)
SALARY NUMBER(6)
SQL> select replace(job_title,'Engineer','Devloper') from employees;

REPLACE(JOB_TITLE,'ENGINEER','DEVLOPER')
--------------------------------------------------------------------------------
Software Devloper
Data Scientist
Devlopering Manager
System Analyst
Cybersecurity Analyst
AI Devloper
Cloud Devloper
DevOps Devloper
Network Devloper
Embeded System Devloper

10 rows selected.

SQL> select concat(name,job_titles) from employees;


select concat(name,job_titles) from employees
*
ERROR at line 1:
ORA-00904: "JOB_TITLES": invalid identifier

SQL> select concat(name,job_title) from employees;

CONCAT(NAME,JOB_TITLE)
--------------------------------------------------
AliceSoftware Engineer
BobData Scientist
CharlieEngineering Manager
DavidSystem Analyst
EveCybersecurity Analyst
FrankAI Engineer
GraceCloud Engineer
HankDevOps Engineer
IvyNetwork Engineer
JakeEmbeded System Engineer

10 rows selected.

SQL> select substr(name,2,4)from employees;

SUBSTR(NAME,2,4)
----------------
lice
ob
harl
avid
ve
rank
race
ank
vy
ake

10 rows selected.
SQL> select round(salary,1000) from employees;

ROUND(SALARY,1000)
------------------
70000
75000
95000
72000
69000
80000
73000

68000
73000

10 rows selected.

SQL> select abs(select max(salary) from employess - select min(salary) from


employees) from employees;
select abs(select max(salary) from employess - select min(salary) from employees)
from employees
*
ERROR at line 1:
ORA-00936: missing expression

SQL> select abs(select max(salary) from employees - select min(salary) from


employees) from employees;
select abs(select max(salary) from employees - select min(salary) from employees)
from employees
*
ERROR at line 1:
ORA-00936: missing expression

SQL> select abs ((select max(salary) from employees - select min(salary) from
employees)) from employees;
select abs ((select max(salary) from employees - select min(salary) from
employees)) from employees
*
ERROR at line 1:
ORA-00907: missing right parenthesis

SQL> select abs ((select max(salary) from employees) - (select min(salary) from
employees)) from employees;

ABS((SELECTMAX(SALARY)FROMEMPLOYEES)-(SELECTMIN(SALARY)FROMEMPLOYEES))
----------------------------------------------------------------------
27000
27000
27000
27000
27000
27000
27000
27000
27000
27000
10 rows selected.

SQL> select sqrt(select max(salary) from employees) from employees;


select sqrt(select max(salary) from employees) from employees
*
ERROR at line 1:
ORA-00936: missing expression

SQL> select sqrt (select max(salary) from employees) from employees;


select sqrt (select max(salary) from employees) from employees
*
ERROR at line 1:
ORA-00936: missing expression

SQL> select power ((select max(salary) from employees),.5) from employees;

POWER((SELECTMAX(SALARY)FROMEMPLOYEES),.5)
------------------------------------------
308.2207
308.2207
308.2207
308.2207
308.2207
308.2207
308.2207
308.2207
308.2207
308.2207

10 rows selected.

SQL> select rand(1,100) from employees;


select rand(1,100) from employees
*
ERROR at line 1:
ORA-00904: "RAND": invalid identifier

SQL> select rand(1,100) from dual;


select rand(1,100) from dual
*
ERROR at line 1:
ORA-00904: "RAND": invalid identifier

SQL> select log(max(employees.salary),10) from dual;


select log(max(employees.salary),10) from dual
*
ERROR at line 1:
ORA-00904: "EMPLOYEES"."SALARY": invalid identifier

SQL> select log((select max(salary) from employees),10) from dual;

LOG((SELECTMAX(SALARY)FROMEMPLOYEES),10)
----------------------------------------
.200895043

SQL> select sysdate(current_date) from duak;


select sysdate(current_date) from duak
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

SQL> select sysdate (current_date) from dual;


select sysdate (current_date) from dual
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

SQL> select sysdate from dual;

SYSDATE
---------
10-FEB-25

You might also like