| |
|
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.
|
 |

11-25-10, 08:51
|
|
Registered User
|
|
Join Date: Nov 2010
Posts: 4
|
|
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
|
|

11-25-10, 10:48
|
|
:-)
|
|
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))
|
|

11-25-10, 11:12
|
|
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
|
|

11-25-10, 11:46
|
|
Registered User
|
|
Join Date: Jan 2010
Posts: 294
|
|
Quote:
Originally Posted by vega!
REMOVIDO VARCHAR(1),
|
alter table TABNAME add constraint PK_NAME primary key (id)
|
|

11-25-10, 12:25
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
Quote:
Originally Posted by vega!
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
|
|

11-25-10, 13:40
|
|
Registered User
|
|
Join Date: Nov 2010
Posts: 4
|
|
Quote:
Originally Posted by n_i
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
|
|

11-26-10, 03:27
|
|
Registered User
|
|
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
|
|
Quote:
Originally Posted by n_i
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
|
|

11-26-10, 08:34
|
|
:-)
|
|
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.
|
|

11-26-10, 10:23
|
|
Registered User
|
|
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
|
|
|
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|