Mar 3, 2010

Syntax difference b/w Oracle and DB2

Create statement in DB2 for aleady existing table
create table tablename like tablename2

select * from dual(in orcl)
SELECT * FROM sysibm.sysdummy1(DB2)

At last of syntax we use With UR(in DB2)
For a SELECT INTO, a FETCH with a read-only cursor, subquery, or subselect used in an INSERT statement, level UR allows:
Any row read during the unit of work to be changed by other activation groups that run under a different commitment definition. 


Any row changed (or a row that is currently locked with an UPDATE row lock) by another activation group running under a different commitment definition to be read even if the change has not been committed.
That's the explanation that comes with the manuals. 


We don't usually use it, only in case a table is locked and we want to see the progress of rows during the insert statement. 



to get first 10 rows in DB2
select * from tablename
fetch first 10 rows only;


In DB2 we cannot delete the data of million rows at a time with single delete command.



Make sure the table is originally created with "not logged initially". In the first step of the delete script, alter the table to be "not logged initially", then run the delete, then execute a commit. The script must be run with auto-commit off (use the +c option on the command line processor).




Date Function in DB2


select * from SCHEMA.TABLENAME where CLIENT_ID='126X9' and 
LOAD_DT = date('02/25/2010')

No comments:

Post a Comment