Tuesday, September 18, 2012

how to create sql profile





DECLARE
 my_task_name VARCHAR2(30);
 my_sqltext CLOB;
 Begin
 my_sqltext := 'select * from emp where empno=66';
 My_Task_Name := Dbms_Sqltune.Create_Tuning_Task(
 Sql_Text=> My_Sqltext,
 user_name => 'SCOTT',
 scope => 'COMPREHENSIVE',
Time_Limit => 60,
 task_name => 'sql_tuning_task_11',
 Description => 'Task to tune a query on a specified table');
 END;

  Exec Dbms_Sqltune.Execute_Tuning_Task( Task_Name => 'my_sql_tuning_task_11');
  SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK( 'my_sql_tuning_task_11') from DUAL;



check sql profile 

select * from dba_Sql_Profiles


delete  sql profile

EXEC DBMS_SQLTUNE.DROP_SQL_PROFILE('NAME');

Friday, September 14, 2012

Show hidden files windows 7

Follow these steps to display hidden files and folders.
  1. Open Folder Options by clicking the Start button , clicking Control Panel, clicking Appearance and Personalization, and then clicking Folder Options.
  2. Click the View tab.
  3. Under Advanced settings, click Show hidden files and folders, and then click OK.

Documents required for marriage certificate in India

You need the below documents for getting marriage certificate in India


  • Marriage Invitation card
  • 2 Photos of Bride and Groom in marriage dress taken during marriage ritual which clearly show they are taking part in marriage cermony.
  • Documents which serve as Proof of Age
    Preferably  10th class marks memo which has your photo and also your date of Birth on it.
  • Address proof of current residing address which should be on Bride or Grooms name.
    • Some of the accepted documents are Passport,Drivers Lisence, Voter ID card, GAS card, Eletricity Bill on the name of the applicant. Atleast one of the applicant should have government issue Residence proof if not booth the applicants.
And 3 witnesses to certify your marriage.

You should go to the sub registrar office of the locality for which you have address proof. They differ based on your plot number/Door number of your address proof.

Monday, September 10, 2012

ORA-00257: archiver error tips

Increase the free space where archiver archives the archivelog. The location where archiver archives the log is determined by parameter file pfile or spfile.


SQL> show parameter log_archive_dest
2.) In case it is not possible to increase free space at the same location but if free space is available at other location then the parameter log_archive_dest (or log_archive_dest_1 in some cases) can be changed so that the new archives are produced at new location specified which has free space.
this can be done by modify init.ora file or using alter system if spfile is present
SQL> alter system set log_archive_dest_1=’
3.) The option which is often used is to take a backup of the archives from the existing place and delete those archives from that place so that new archives can generated at that place .
the backup can be OS level backup and OS level del;etion but the recommended method which is compulsory to be used with ASM in place is taking any RMAN backup and delete using RMAN. as shown
rman target sys/sys
RMAN> backup archive log all device type disk format ‘/oracle/arch_%U’;
RMAN> delete archive until time ‘trunc(sysdate)’;
This will delete all the archive logs until today and space will freed and the archiver will start archiving redo logs

What are joins..how many types of joins are there?

A join is a query that extracts data from two or more tables, views or snapshots.

1. Equi Join
2.Non Equijoin
3.outer joins
4.self joins 
 

To get second highest age from the student table 

 
SELECT * FROM (SELECT s.*, rownum age_rank
 FROM (SELECT * FROM student ORDER BY age DESC) s) WHERE age_rank=2
 
 

Write a query to display alternate records from the employee table?

SELECT * FROM emp WHERE ROWID IN 
(SELECT DECODE(MOD(ROWNUM,2),0,ROWID, NULL) FROM emp);

 

 
 

What is difference between DELETE & TRUNCATE commands?

Delete command removes the rows from a table based on the condition that we provide with a WHERE
clause. Truncate will actually remove all the rows from a table and there will be no data in the table
after we run the truncate command.

TRUNCATE
TRUNCATE is faster and uses fewer system and transaction log resources than DELETE.
TRUNCATE removes the data by deallocating the data pages used to store the table’s data, and only the
page deallocations are recorded in the transaction log.
TRUNCATE removes all rows from a table, but the table structure and its columns, constraints, indexes
and so on remain. The counter used by an identity for new rows is reset to the seed for the column.
You cannot use TRUNCATE TABLE on a table referenced by a FOREIGN KEY constraint.
Because TRUNCATE TABLE is not logged, it cannot activate a trigger.
TRUNCATE can not be Rolled back.
TRUNCATE is DDL Command.
TRUNCATE Resets identity of the table.

DELETE
DELETE removes rows one at a time and records an entry in the transaction log for each deleted row.
If you want to retain the identity counter, use DELETE instead. If you want to remove table definition
and its data, use the DROP TABLE statement.
DELETE Can be used with or without a WHERE clause
DELETE Activates Triggers.
DELETE Can be Rolled back.
DELETE is DML Command.
DELETE does not reset identity of the table.

What are different normalization forms?

1NF: Eliminate Repeating Groups
Make a separate table for each set of related attributes, and give each table a primary key. Each field
contains at most one value from its attribute domain.
2NF: Eliminate Redundant Data
If an attribute depends on only part of a multi-valued key, remove it to a separate table.
3NF: Eliminate Columns Not Dependent On Key
If attributes do not contribute to a description of the key, remove them to a separate table. All
attributes must be directly dependent on the primary key
BCNF: Boyce-Codd Normal Form
If there are non-trivial dependencies between candidate key attributes, separate them out into distinct
tables.
4NF: Isolate Independent Multiple Relationships
No table may contain two or more 1:n or n:m relationships that are not directly related.
5NF: Isolate Semantically Related Multiple Relationships
There may be practical constrains on information that justify separating logically related many-to-many
relationships.
ONF: Optimal Normal Form
A model limited to only simple (elemental) facts, as expressed in Object Role Model notation.
DKNF: Domain-Key Normal Form
A model free from all modification anomalies.

Remember, these normalization guidelines are cumulative. For a database to be in 3NF, it must first
fulfill all the criteria of a 2NF and 1NF database.