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

User

The document provides information on connecting to an Oracle database and managing users and permissions. It also describes various data types supported in Oracle such as CHAR, VARCHAR2, NUMBER, DATE and BLOB. Key points include: - To connect as the SYSTEM user with password TIGER or as SYSTEM/TIGER. Only DBAs can create new users with the CREATE USER statement. - Common data types include CHAR and VARCHAR2 for character data, NUMBER for numeric data, DATE for dates, and BLOB for binary objects like images. - NUMBER allows exact or approximate numeric data depending on if a scale is specified. DATE stores dates and optional times in a standard format.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

User

The document provides information on connecting to an Oracle database and managing users and permissions. It also describes various data types supported in Oracle such as CHAR, VARCHAR2, NUMBER, DATE and BLOB. Key points include: - To connect as the SYSTEM user with password TIGER or as SYSTEM/TIGER. Only DBAs can create new users with the CREATE USER statement. - Common data types include CHAR and VARCHAR2 for character data, NUMBER for numeric data, DATE for dates, and BLOB for binary objects like images. - NUMBER allows exact or approximate numeric data depending on if a scale is specified. DATE stores dates and optional times in a standard format.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

How to connect to ORACLE/SQL :-

---------------------------

=> to connect to oracle open sqlplus and enter username & password

username :- SYSTEM
password :- TIGER/MANAGER/at the time of installlation

OR

username :- SYSTEM/TIGER

creating users in oracle db :-


-----------------------------

=> only DBAs are having permissions to create new users.

step 1 :- conn as system/TIGER

username :- system/TIGER

step 2 :- create user

syntax :-

CREATE USER <NAME> IDENTIFIED BY <PWD>


DEFAULT TABLESPACE USERS
QUOTA UNLIMITED ON USERS;

Ex :-

SQL>CREATE USER C##7AM IDENTIFIED BY ORACLE


DEFAULT TABLESPACE USERS
QUOTA UNLIMITED ON USERS ;

=> a user is created but user is not having permissions to connect


to db and to create objects.

step 3 :- granting permissions to user

SQL>GRANT CONNECT,RESOURCE TO C##7AM ;

CONNECT => to connect to db


RESOURCE => to create objects
DBA => all permissions

changing password :-
---------------------

=> both user,DBA can change password.

by user :- (c##7AM/ORACLE)
----------

SQL>PASSWORD
changing password for c##7am
old password :- ORACLE
new password :- TIGER
retype new password :- TIGER
password changed

by dba :- (system/manager)
-----------

SQL>ALTER USER C##7AM IDENTIFIED BY NARESH ;

Datatypes in ORACLE :-
----------------------

=> a datatype specifies type of the data allowed in a column and


amount of memory should be allocated for column.

DATATYPES

CHAR NUMERIC DATE BINARY

ASCII UNICODE number(p) date bfile


char nchar number(p,s) timestamp blob
varchar2 nvarchar2
long nclob
clob

CHAR(size) :-
-------------

=> allows character data upto 2000 chars

ex :- NAME CHAR(10)

vijay-----
wasted

ravi------
wasted

=> in CHAR datatype extra bytes are wasted , so don't use CHAR
datatype of variable length fields and use CHAR datatype for
fixed length fields.

ex :- GENDER CHAR(1)
M
F

STATE_CODE CHAR(2)
AP
TS
MH

COUNTRY_CODE CHAR(3)
IND
USA
VARCHAR2(SIZE) :-
-----------------

=> allows character data upto 4000 chars


=> in VARCHAR2 extra bytes are released
=> VARCHAR2 recommended for variable length fields.

ex :- NAME VARCHAR2(10)

vijay-----
released

ravi------
released

=> both CHAR/VARCHAR2 allows ascii characters (256 chars) that


includes a-z,A-Z,0-9 and special chars.

ex :- panno char(10)
vehno char(10)
emailid varchar2(30)

LONG :- allows character data upto 2GB

FEEDBACK LONG

CLOB :- (character large object)

=> allows character data upto 4GB.

NCHAR/NVARCHAR2/NCLOB :- ( N => National)


-------------------------

=> allows unicode characters (65536 chars) that includes all


ascii chars and characters belongs to different languages.

=> ascii char takes 1 byte and unicode char takes 2 bytes

Number(p) :-
-------------

=> allows numeric data upto 38 digits


=> allows exact numbers i.e. numbers without decimal part

ex :- EMPID NUMBER(4)

10
100
1000
10000 not accepted

Number(P,S) :-
---------------

=> allows approximate numbers i.e. numbers with decimal part.

p => precision => total no of digits allowed


s => scale => no of digits allowed after decimal
ex :- salary Number(7,2)

5000
5000.50
50000.50
500000.50 => not accepted
5000.507 => accepted => 5000.51
5000.503 => accepted => 5000.50
5000.1234 => accepted => 5000.12

DATE :-
-------

=> allows date & time


=> time is optional , if not entered then oracle stores 12:00AM.
=> default date format is DD-MON-YY / YYYY
=> dates can be between 01 JAN 4712BC TO 31 DEC 9999AD

EX :- DOB DATE

01-MAY-21 01-MAY-2021
15-AUG-95 15-AUG-2095
15-AUG-1995 15-AUG-1995

TIMESTAMP :-
------------

=> allows date,time and also milliseconds

T TIMESTAMP

01-MAY-21 7:56:00.123
--------- -------- ---
DATE TIME MS

BLOB/BFILE :-

=> both allows multimedia objects like audio,video,images

BFILE :- (binary file)


----------------------

=> BFILE is called external lob because lob stored outside db but
db stores path.

BLOB :- (binary large object)


-------------------------------

=> BLOB is called internal lob because lob stored inside the db.
=> BLOB allows multimedia objects upto 4GB.

CPHOTO BFILE
SIGN BLOB

You might also like