Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Create table with default value

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Mon May 11, 2009 10:44 am    Post subject: Create table with default value
Reply with quote

Hi All,
My requirement is as follows,
I want to create a table which has a column of 120 byte varchar,i want to fill default value as 40 spaces.Is it possible to give 40 spaces in to that??

Regards,
Bipin Peter
Back to top
View user's profile Send private message

sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Mon May 11, 2009 2:57 pm    Post subject:
Reply with quote

Bipin,

In the Create table
WITH DEFAULT ' '
You can do it.

Can i know why 40 spaces by default for VARCHAR that too.

Sushanth
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon May 11, 2009 5:19 pm    Post subject:
Reply with quote

I think the CREATE Table statement for the VARCHAR column would be
Code:

WITH DEFAULT '                                        '


this would be the same as
Code:

HIRE_TYPE    VARCHAR(50) WITH DEFAULT 'New Hire'


the first would generate a textlength of 40 for the varchar(120)
the second would generate a textlength of 8 for the varchar(50).


Sushanth, if that is what you tried to show, you need the bbcode to maintain the spaces,
otherwise you would have generated a textlength of 1 for the varchar(120)
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Mon May 11, 2009 6:31 pm    Post subject:
Reply with quote

Yes Dino.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us