IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sql query to compress a data field


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sumit agarwalla

New User


Joined: 13 Nov 2008
Posts: 17
Location: hyderabad

PostPosted: Tue Dec 30, 2008 9:53 am
Reply with quote

I have to create a table in which one of the fields is CITY of datatype CHAR(15).....and I have to use some sort of compressing the alphabetic field CITY ......how do I compress the field while creating it...please help me on this?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Dec 30, 2008 11:39 pm
Reply with quote

Hello,

Quote:
I have to use some sort of compressing the alphabetic field CITY
You have received no replies because you have not posted anything for people to use to help you. . .

You need to define what you mean by "compress" and what the compression rules are for this requirement.

Post a variety of city names as they "are" and how you want them to be compressed.
Back to top
View user's profile Send private message
sumit agarwalla

New User


Joined: 13 Nov 2008
Posts: 17
Location: hyderabad

PostPosted: Wed Dec 31, 2008 11:55 am
Reply with quote

ok...i will explain what i require....
I need to create an employee table named "EMPLOYEEDET" with the following characteristics

Code:

COLUMNNAME       DATATYPE     LENGTH            REMARKS
dept_id              numeric       4         foreign key which refers the
                                                      corresponding column in the
                                                      parent table "DEPARTMENT"
emp_no               numeric       4         primary key
firstname            alphabetic    15
lastname             alphabetic    15
city                 alphabetic    15        use some sort of compressing the
                                                      alphabetic field city
gender               alphabetic    1         gender should be M or F.it should not
                                                     allow to enter any other character
                                                     other than M and F
age                  NUmeric        4
salary               numeric        integer:8
                                    decimal:2
doj                   date             10
now i just have to create the table with following remarks being followed but i am not able to understand the remark of the city field. what does it mean?
what i did next to go forward was first i created the table with city fields datatype as CHAR and later on altered the table by changing the datatype from CHAR TO VARCHAR which I think will occupy less space then CHAR.Suggest me if I am wrong.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Wed Dec 31, 2008 4:28 pm
Reply with quote

Sumit,

My suggestion can be, create a table called CITY containing city_code CHAR(4) & city_nameCHAR(30). In this table use city_code CHAR(4).

CHAR TO VARCHAR : Depends on the REQUIREMENT.

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

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Dec 31, 2008 10:25 pm
Reply with quote

Hello,

Quote:
use some sort of compressing the
alphabetic field city
Basically - nonsense. . . icon_confused.gif "Some sort of compressing" is incredibly poor direction.
Quote:
later on altered the table by changing the datatype from CHAR TO VARCHAR which I think will occupy less space then CHAR.
A small amount of space might be saved, but keep in mind it would be a small amount.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top