Oracle 19C

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

ORACLE 19C

Oracle is a relational database which is used to store data permanently in


secondary storage devices. If we want to operate oracle, then we are using
following languages.
They are,
1. SQL
2. PL / SQL
3. Dynamic SQL

If any user wants to perform some operations on oracle database, then that
user uses following 2 step process.
Step 1:- CONNECT  Ex:- SQL plus tool
Step 2:- Communication  Ex:- SQL, PL/SQL languages

If any user wants to perform some operations in oracle database, then those
users first connect to oracle database by using client tool.
Whenever we are installing oracle software then automatically SQL plus tool is
created. That is why SQL plus is a default tool.
Ex:- SQL Plus tool
SQL Plus is an interactive query tool installed automatically when you install
oracle software. SQL Plus has a command line interface that allows users to
connect to oracle database server and executes statements interactively.

User name: system


Pwd: manager (manager is olden days, installation given password)
Every Oracle version having following editions. They are
1. Express Edition
2. Enterprise Edition
In these 2 editions by default user name is “system” and password is
“manager”.
Express Edition:
Oracle server has 2 parts – Hard disk and Ram memory.
All permanently created tables will be stored in hard disk. When any query
requested data will be pulled from hard disk to Ram and then details will be
shown to user.
If we do any modifications to the table, changes happen in Ram. Once we
commit then only the changes permanently get updated in hard disk table.
Before commit if we use rollback, changes done will be reverted in Ram and
the table in hard disk remains same.
Once committed permanent changes happens in hard disk table and there will
not be any changes even after using rollback.
Few commands:
To View current user:
Sql>show user;

To clear screen:
Sql>cl scr;

To view all tables of a particular user:


Sql>select * from tab;
To view particular table:
Sql>select * from tablename;

Eg:
Sql>select * from emp;
In sqlplus tool by default each line having maximum 80 bytes. In our table any
line having more than 80 bytes then that table does not display properly. To
overcome this problem then we mush linesize sqlplus environment variable by
using following syntax.

Sql>set linesize anynumber;


Sql>set line 100;

In Sqlplus tool by default each page having maximum 14 rows. Whenever our
table having more than 14 lines then automatically column names are
repeated in a table. To overcome this problem then we must set sqlplus tool
pagesize environment variable by using following syntax.
Sql>set pagesize anynumber;

Note: Oracle 18C introduced window option along with set linesize command.
Sql>set linesize window;
This command dynamically change and format the displayed output to fit the
screen or window size.
When we are using this command then we are not require to use pagesize
command.
If we want to view all predefined sqlplus tool environment commands and
related default values then we are using following syntax
Sql>show all;
Oracle 19C installation process

Step1: Go to Google -> Oracle software download -> database -> oracle
Enterprise Edition -> Microsoft windows 64 bit zip
Step2: Download oracle 19c
Step3: Extract files
Step4: WINDOWS.X64_193000_db_home
Step5: double click that file and then select setup.exe
Step6: select first radio button – Create and configure a single instance
database. This option creates a starter database
Step7: Select first radio button – Desktop class
Step8: Select – use windows built in account – Yes
Step9:
Oracle base
Software location
Database file location
Database Edition Enterprise Edition
Character set
Global database name: orcl
Password – own password
Don’t choose – Create container database
Note: Are you sure you want to continue – Yes
Automatically installed oracle 19c database – Finish

831 9929 8855


passcode:281493
Step 2: Communication:
If any user wants to perform some operations in oracle database then those
users are allowed to use SQL (Structured Query Language)
Generally sql language is an ANSI standard language which is used to operate
all relational databases. From this ANSI standard sql, oracle corporation
created their own sql language.
Every sql language having following sql languages. Those are,
1. Data Definition Language (DDL)
Create
Alter
Drop
Truncate
Rename (Oracle 9i)

2. Data Manipulation Language (DML)


Insert
Update
Delete
Merge (Oracle 9i)

3. Data Retrieval Language (DRL) / Data Query Language (DQL)


Select

4. Transaction Control Language (TCL)


Commit (Save)
Rollback
Savepoint

5. Data Control Language (DCL)


Grant
Revoke
Data types: Data types specifies type of data within a table column.
Oracle having following datatypes. These are

Char -- Varchr2(Size)


Number(p,s)
Date

Char: It is used to store fixed length alpha-numeric data in bytes

Syntax: Column name char(size)

Maximum size of the Char datatype is up to 2000 bytes.


In Oracle by default Char datatype having 1 byte.

Syntax: Column name Char

In Oracle whenever we are using char datatype and also when we try to
store less number of bytes than the maximum size specified in char
datatype then oracle server internally automatically adds blank spaces in
place of remaining bytes to the end of the string. This is called blank
padded mechanism.
Varchar2(size): Oracle 7.0 introduced varchar2 datatype. It is used to
store variable length alpha-numeric data in bytes.

Syntax: column name varchar2(size)


Max size of varchar2 datatype is up to 4000 bytes.

Whenever we are using varchar2 datatype and also when we try to store
less number of bytes than the maximum size specified in varchar2
declaration then oracle server does not blank spaces in place of
remaining bytes. That’s why here disk space never wasted.

In Oracle when we try to store more number of bytes than the maximum
size specified in varchar2 datatype then oracle server returns an error
Date: It is used to store dates in oracle date format

Syntax: Column_name date

In oracle by default date format is DD-MON-YY

Number(p,s): It is used to store floating point values

P – precession: Total number of digits


S – Scale

Syntax: column_name number(p,s)


Note1: Oracle server returns an error when we try to specify more than
“p minus s” (p-s) number of digits before decimal point when we are
using number (p,s) format.

i.e; number(p,s)  p-s


ex: number(7,2)  7-2 = 5

Note2: Oracle server doesn’t return any error when we try to specify
more number of digits after decimal point than the scale size specified in
declaration. Because in this case oracle server internally automatically
round that number based on the scale size in declaration.
Number(p): It is used to store integers only. It does not store floating
point values

Syntax: Column_name number(p)

Maximum size of precession is up to 38 digits


Create: It is used to create

Ex: sql>desc first


Alter: It is used to change structure of the existing table

Add: It is used to add columns into the existing table

Ex: sql>alter table first add sal number(10);


Sql>desc first;

Modify: It is used to change column data type or column data type size.
Alter ….. drop: It is used to remove columns from existing table

In oracle if we want to drop columns from existing table then oracle


provided following 2 methods.

Method1: In Oracle if we want to drop a single column at a time without


using parenthesis then we are using following syntax.

Syntax: alter table tablename drop column columnname

Method2: In oracle if we want to drop single or multiple columns at a


time with using parenthesis then we are using following syntax.
Note: In all relational databases we cannot drop all columns in a table

Drop: It is used to remove data base objects from database. In all


relational databases we are allowed to drop only one database object at
a time.
Dropping a table:

You might also like