Thursday, October 6, 2011

Oracle Data Loader

Oracle Data Loader takes Data from any external file. Here I'll perform Oracle Data Loader from an excel file (CSV Format).
First make an excel file. Check the Image. Kindly save it in CSV format. I have saved the Excel File as 'Emp_Info.csv' as destination 'E:\Ex_Dir\Emp_Info.csv'
After making Excel Sheet, Connect to SysDba to make directory and also to give the privileges to any common user for read and write the directory. Mostly Scott and other Users unable to make directory and read, write it because of less priveleges.
Conn sys/oracle as Sysdba;
Create Directory EXDIR as 'E:\Ex_Dir';
You can give any name as Directory name but make sure the destination would be the same where you have saved the excel sheet like (as 'E:\Ex_Dir')
After that give the rights to any user you want.
Grant All on Directory EXDIR to Scott;
or 
GRANT READ, WRITE ON DIRECTORY EXDIR TO SCOTT;

Now Connect to Scott.
& Write the following Code.

CREATE TABLE EX_ABC
(
ID NUMBER,
FNAME VARCHAR2(20),
JOB VARCHAR2(20)
)
ORGANIZATION EXTERNAL
(
TYPE ORACLE_LOADER DEFAULT DIRECTORY EXDIR
ACCESS PARAMETERS
(
FIELDS TERMINATED BY ','
)
LOCATION ('EMP_INFO.csv'))

The Attributes should be in the same manner/format datatype like your excel sheet. 
Here (FIELDS TERMINATED BY ',')  indicates that you have made comma separated file,
LOCATION ('EMP_INFO.csv')) indicates your excel file name.

 Thank you. . .  !!
Have a Nice Day...!!!! 




Saturday, October 1, 2011

SQL Server- Encryption/Decryption (functions, procedures, triggers and views)


I have made some functions, procedures, triggers and views in SQL Server 2008 its level was encrypted by using “WITH ENCRYPTION”. I was looking to secure my functions, procedures, triggers and views secure so that no one would be able to use it.
After having some sort of working, I came to know that if the procedure or user defined function created “WITH ENCRYPTION”, there is no possible ways to decrypt it by SQL Server commands.
Well, if anyone wants to decrypt it then you will have to use the freeware “Optillect SQL Decryptor”. It will decrypt your functions, procedures, triggers and views.
Just download “Optillect SQL Decryptor” , connect it by using your desired connection and decrypt it whatever you want.
Have a nice Day..!

Thursday, July 14, 2011

Some Useful Data Dictionary VIEWS

Table spaces


dba_tablespacesuser_tablespaces 

Tablespace Quotas

dba_ts_quotas
user_ts_quotas
Data Files

dba_data_files
v$backup_datafile
v$datafile
v$datafile_copy
v$datafile_header
Free Space

dba_free_space
Segments

dba_segments
v$segment_statistics
Extents

dba_extents
Blocks

v$database_block_corruption

Groups
dba_tablespace_groups
SYSAUX Tablespace
v_$sysaux_occupants
Temp Tablespace
dba_temp_files
Undo Tablespace
dba_rollback_segs
dba_undo_extents
v$rollstat
v$undostat
Transportable Tablespaces
transport_set_violations

Saturday, June 25, 2011

Connect Oracle10g Database with DotNet Framework using C#


Namespaces


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

Button Click Event to Display Data on DataGridView


private void button1_Click(object sender, EventArgs e)
{
string connectionString = "provider=MSDAORA;data source=ORCL;user id=SCOTT;password=TIGER";
OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);
OleDbDataAdapter da = new OleDbDataAdapter("select * from emp",myOleDbConnection );
DataSet ds = new DataSet();
da.Fill(ds, "emp");
dataGridView1.DataSource = ds.Tables["EMP"].DefaultView;
}


Monday, March 21, 2011

DROP TABLE - PURGE

Oracle Database 10g gives you the extra feature to drop your table and put them in the Recycle bin, This feature was introduced in 10g and it's not in earlier versions. Once you drop the table you can use Flashback query to retrieve that table from the Recycle bin.
If you want to remove the table permanently from the database also from Recycle bin then you have to use PURGE (just like shift+delete key in Windows).
And you cannot roll back Drop Table and Purge Clause.

Syntax given below.

Drop Table Table_name Purge;
It'll permanently remove and clears your storage space.

Drop Table Table_name
It will drop the table and send that table into the Recycle Bin.

Flashback Table Table_name to Before drop;
It will retrieve the Table from the Recycle Bin.

And also you can use this query to retrieve from Recycle Bin.

Select original_name, operation, droptime, from recyclebin;
Where Original_name is the table_name
Operation is drop that you did perform
Droptime, At what time you dropped the table.

To Clear the RecycleBin,
PURGE RECYCLEBIN;

Wednesday, March 2, 2011

Syed Sharique Imam: Different Types of Joins-

Syed Sharique Imam: Different Types of Joins-: "Joins A range of new join syntax are available that comply with the ANSI/ISO SQL: 1999 standards. CROSS JOIN The CROSS JOIN produces a ca..."

Tuesday, March 1, 2011

Different Types of Joins-

Joins

A range of new join syntax are available that comply with the ANSI/ISO SQL: 1999 standards.

CROSS JOIN

The CROSS JOIN produces a cartesian product.

ANSI/ISO Syntax

select e.ename, d.dname
from emp e cross join dept d;

Existing Syntax
select e.ename, d.dname
from emp e , dept d ;

NATURAL JOIN

The NATURAL JOIN performs a join for all columns with matching names in the two tables.

ANSI/ISO Syntax

select e.ename, d.dname
from emp e natural join dept d;

Existing Syntax

select e.ename, d.dname
from emp e , dept d
where e.deptno = d.deptno;

JOIN ... USING

The USING clause is used if several columns share the same name, but you do not wish to join using all of these common columns. The columns listed in the USING clause cannot have any qualifiers in the statement, including the WHERE clause.


ANSI/ISO Syntax

select e.ename, e.job, d.dname
from emp e join dept d
using (deptno)

Existing Syntax

select e.ename, e.job, d.dname
from emp e , dept d
where e.deptno = d.deptno

Multiple Joins

Multiple Joins are those where more than two tables are joined

ANSI/ISO Syntax

select first_name, last_name, department_name, city
from employees e join departments d on (e.department_id = d.department_id)
join locations l on (d.location_id = l.location_id)

Existing Syntax

select first_name, last_name, department_name, city
from employees e , departments d , locations l
where e.department_id = d.department_id
and d.location_id = l.location_id

OUTER JOIN

There are three variations on the outer join. The LEFT OUTER JOIN returns all the rows from the table on the left side of the join, along with the values from the right hand side, or NULLs if a matching row doesn't exist. The RIGHT OUTER JOIN does the reverse of this. Finally, the FULL OUTER JOIN returns all rows from both tables, filling in any blanks with nulls.


ANSI/ISO Syntax

select l.city, d.department_name
from locations l
left outer join
departments d
on (l.location_id = d.location_id)


Existing Syntax

select l.city, d.department_name
from locations l , departments d
where l.location_id = d.location_id(+)


ANSI/ISO Syntax

select l.city, d.department_name
from locations l
right outer join
departments d
on (l.location_id = d.location_id)


Existing Syntax

select l.city, d.department_name
from locations l , departments d
where l.location_id(+) = d.location_id


ANSI/ISO Syntax

select l.city, d.department_name
from locations l
full outer join
departments d
on (l.location_id = d.location_id)


Existing Syntax

No Equivalent!