If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Convert sql code to Db2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-25-10, 08:51
vega! vega! is offline
Registered User
 
Join Date: Nov 2010
Posts: 4
Talking Convert sql code to Db2

Hi,

Please i need help to convert my Oracle bases in Db2 .
I want one little example , because all the database is the same.

Code SQL:

CREATE TABLE MATRIZAVALIACAORISCORESIDUAL(
ID INTEGER NOT NULL,
TITULO varchar2(750) NULL,
REMOVIDO varchar2(1) NULL,
CONSTRAINT PKMATRIZAVALIACAORISCORESIDUAL PRIMARY KEY (ID)
);



My code DB2

create table dddd
(ID SMALLINT NOT NULL,
TITULO VARCHAR(250),
REMOVIDO VARCHAR(1),
PRIMARY KEY (ID) )

Its works, but don't declare the constraint.
Please, i need to declare this constraint.

Thank you
Reply With Quote
  #2 (permalink)  
Old 11-25-10, 10:48
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Code:
create table dddd
(ID SMALLINT NOT NULL PRIMARY KEY ,
TITULO VARCHAR(250),
REMOVIDO VARCHAR(1))
Reply With Quote
  #3 (permalink)  
Old 11-25-10, 11:12
vega! vega! is offline
Registered User
 
Join Date: Nov 2010
Posts: 4
THKS.. solves the primary key problem , but
I need the name of Primary_Key Constraint to log efects.

Thks
Reply With Quote
  #4 (permalink)  
Old 11-25-10, 11:46
nvk@vhv nvk@vhv is offline
Registered User
 
Join Date: Jan 2010
Posts: 294
Quote:
Originally Posted by vega! View Post
REMOVIDO VARCHAR(1),


alter table TABNAME add constraint PK_NAME primary key (id)
Reply With Quote
  #5 (permalink)  
Old 11-25-10, 12:25
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by vega! View Post
THKS.. solves the primary key problem , but
I need the name of Primary_Key Constraint to log efects.
Which DB2 version are you working with?

Code:
CREATE TABLE MATRIZAVALIACAORISCORESIDUAL(
ID INTEGER NOT NULL,
TITULO varchar2(750) ,
REMOVIDO varchar2(1) ,
CONSTRAINT PKMATRIZAVALIACAORISCORESIDUAL PRIMARY KEY (ID)
);
The above works for me. You only need to remove the NULL default declarations, because they don't make sense anyway.

It might be a good idea for you to start reading the DB2 manuals. http://publib.boulder.ibm.com/infoce...v9r7/index.jsp
Reply With Quote
  #6 (permalink)  
Old 11-25-10, 13:40
vega! vega! is offline
Registered User
 
Join Date: Nov 2010
Posts: 4
Quote:
Originally Posted by n_i View Post
Which DB2 version are you working with?

Code:
CREATE TABLE MATRIZAVALIACAORISCORESIDUAL(
ID INTEGER NOT NULL,
TITULO varchar2(750) ,
REMOVIDO varchar2(1) ,
CONSTRAINT PKMATRIZAVALIACAORISCORESIDUAL PRIMARY KEY (ID)
);
The above works for me. You only need to remove the NULL default declarations, because they don't make sense anyway.

It might be a good idea for you to start reading the DB2 manuals. IBM DB2 9.7 for Linux, UNIX and Windows Information Center
Thks.. solve the problem.
I don't put the codom.
Thanks
Reply With Quote
  #7 (permalink)  
Old 11-26-10, 03:27
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Quote:
Originally Posted by n_i View Post
You only need to remove the NULL default declarations, because they don't make sense anyway.[
The NULL default declarations don't hurt anything and make things explicit. If this is preferred, just leave them be.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #8 (permalink)  
Old 11-26-10, 08:34
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
This is why I asked about the DB2 version - explicit declarations of NULL column defaults were not supported until 9.7 fp2 I think.
Reply With Quote
  #9 (permalink)  
Old 11-26-10, 10:23
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Yeah, right...
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On