Types to Start SQL
Transcript of Types to Start SQL
-
8/6/2019 Types to Start SQL
1/23
Developed By
- Dalwadi manish .S U BMITTED TO
----------
The presentation on
-
8/6/2019 Types to Start SQL
2/23
Types to start SQL*Plus
Dos Base
In isql*plusUsing SQL*Plus
-
8/6/2019 Types to Start SQL
3/23
For Starting Sql*Plus inDos We have to Just Write
down in Dos :=
sqlplusFor Ex :=
C:\Document and Setting\ssit>sqlplus
D os Base
-
8/6/2019 Types to Start SQL
4/23
-
8/6/2019 Types to Start SQL
5/23
SQl In isqlplus
SQL Also start with isqlplus.
For start isqlplus we have to open Web Browser (InternetExplorer).
After opening internet explorer we just write down
http://localhost/isqlplusAfter writing this link in link barIsqlplus is start.
-
8/6/2019 Types to Start SQL
6/23
-
8/6/2019 Types to Start SQL
7/23
-
8/6/2019 Types to Start SQL
8/23
In isql*plus we can easily
save our data.
SELECT last_name, hire_date, salary
FROM employees;1
2
-
8/6/2019 Types to Start SQL
9/23
And Easily load our data.
1
D:\ temp \ emp_sql
SELECT last_name, hire_date, salaryFROM employees;
3
-
8/6/2019 Types to Start SQL
10/23
SQL start using SQL*Plus.
In SQL*Plus Different types of username &Passwords .
User name = scottPassword = tiger
Uname = /as sysdbaUname = systemPassword =
admin
U sing SQl*Plus
SystemDatabase
-
8/6/2019 Types to Start SQL
11/23
C reate U ser
In SQL*Plus create our own user .
We have to just login to /as sysdba .
/as sysdba is mostly used For any insertion, updation,deletion about user
SQL>CONNECT /AS SYSDBA;
SQL>CREATE USER SSIT IDENTIF IED BY SSIT;
Username Password
-
8/6/2019 Types to Start SQL
12/23
After create user we have to give a permission to use andconnect this user.
For giving a permission tothis user we have to write down :=
Ex:=
SQL>grant resource, connect to ssit;
OR
SQL>grant create session, create table, create procedure,2 create sequence, create view, create trigger to ssit;
G rant
Used for granting
-
8/6/2019 Types to Start SQL
13/23
R evoke
Privileges once given can be denied to a user using theREVOKE command.
The object owner can revoke priveleges granted to anotheruser.
A user of an object who is not the owner, but has beengranted the grant priveleges, has the power to REVOKE the
priveleges from a grantee.
R evoking Permission Using the R EVOK E statement.
-
8/6/2019 Types to Start SQL
14/23
SQL>revoke resource, connect from ssit;
OR
SQL>revoke create session, create table, create procedure,2 create sequence, create view, create trigger to ssit;
-
8/6/2019 Types to Start SQL
15/23
Lock & U nlock U ser
If we want to lock on our user accountThen
SQL>alter user ssit account lock;
When we want to unlock our user account then
SQL>alter user ssit account unlock;
-
8/6/2019 Types to Start SQL
16/23
In SQL*Plus see all tables we are write down
SQL> select * from tab;
B ut
SQL>select table_name from user_tables;
Both are doing same work.
D isplay Tables
-
8/6/2019 Types to Start SQL
17/23
C onstraints
There are five types of constraints.
1. Primary key2. Unique
3. Not Null4. Check5. Foreign Key
After giving a any type of constraints in any table
If We want to check that the in which table on a which field wegiven a constraints.
-
8/6/2019 Types to Start SQL
18/23
F irst write down this query.
SQL> desc user_constraints;this query will display all types of conditions and
then u can select and check your constraints.
Like :=Name----------------------OWNERCONSTRAINT_NAMECONSTRAINT_TYPETABLE_NAMESEARCH_CONDITIONR_CONSTRAINT_NAME
-
8/6/2019 Types to Start SQL
19/23
SQL> selectowner,constraint_name,constraint_type,search_condition,table_name from user_constraints;
OWNER TABLE_NAME CONSTRAINT_NAME C SEARCH_CONDITION------------- ------------------ ----------------------------- --- -----------------------------------SCOTT DEPARTMENT PK_DEPTCODE PSCOTT DEPARTMENT CK_DEPTCODE C deptcode like 'D%'SCOTT DEPARTMENT UQ_DNAME USCOTT DEPARTMENT CK_DHEAD C dhead like 'MR%'SCOTT DEPARTMENT CK_REGION C regionin
('east','EAST','west','WEST','north','NORTH','south','SOUTH')
SCOTT EMPLOYEE CK_EOJ C edoj>edobSCOTT EMPLOYEE UQ_EMAIL U
Constraint_type
-
8/6/2019 Types to Start SQL
20/23
Save D ataIn SQL*Plus for saving data
Syntax :=spool spoolname
Ex :=
SQL>Spool SSITMCA
in spool name space is not required. If space is occur thenError will be display on screen.Like :=
SQL>spool SSIT MCA
SP2-0333: Illegal spool file name: "SSIT MCA" (bad character: ' ')
-
8/6/2019 Types to Start SQL
21/23
Whenever your work will be complete u have to write down
SQL>spool off
Saving All
Data as any ExtensionSave the data as a .csv extension.
Syntax :=spool drivename:\.csv
Ex :=
SQL>spool C:\SSIT.docWhere data youhave to store ?
-
8/6/2019 Types to Start SQL
22/23
Save Each data
If you want to save your data each query wise &save your data with any extension wise,Then
SQL>save c:\SSIT.sqlSQL>Save c:\SSIT.docSQL>Save c:\SSIT.csv
For comment line use -- symbol.
SQL>--SSIT Records
-
8/6/2019 Types to Start SQL
23/23