473,395 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Load command on table, field timestamp primary key

jay
hi,
Question on Load/import command.
consider a sample table
create table table_name (
col1 timestamp not null default current timestamp,
col2 int,
col3 int,
col4 int,
primary key(col1) );
There is a file file.del containing data for col2,col3,col4. Data for
col1 is missing.

Is there a way I can use load/import command to get data into above
table from file? How would I insert timestamp values into col1?
Running DB2 Ver 7.2.0 on RedHat 8.0.

Any feedback is highly appreciated,
thanks
jay

Nov 12 '05 #1
2 5790
jay wrote:
hi,
Question on Load/import command.
consider a sample table
create table table_name (
col1 timestamp not null default current timestamp,
col2 int,
col3 int,
col4 int,
primary key(col1) );
There is a file file.del containing data for col2,col3,col4. Data for
col1 is missing.

Is there a way I can use load/import command to get data into above
table from file? How would I insert timestamp values into col1?
Running DB2 Ver 7.2.0 on RedHat 8.0.

Any feedback is highly appreciated,
thanks
jay


What you have described is inconsistent and will not work, unless you
want to and can do a s-l-o-w load, one that is slow enough that the
time stamp will change between loading one row and the next! If you
remove the requirement that col1 be a primary key, the load command
would be simply:

load from <filename> of del modified by coldel, insert into
table_name(col2,col3,col4);

To add time-stamps later, you would do an UPDATE.

Here is what I get with the primary key requirement removed (as you can
see, all four rows were loaded before the timestamp changed):

db2 => select * from table_name;

COL1 COL2 COL3 COL4
-------------------------- ----------- ----------- -----------
2005-02-19-10.48.22.275928 11 12 13
2005-02-19-10.48.22.275928 21 22 23
2005-02-19-10.48.22.275928 31 32 33
2005-02-19-10.48.22.275928 41 42 43

4 record(s) selected.

:- N. Shamsundar
:- University of Houston
Nov 12 '05 #2
mecej4 wrote:
jay wrote:
hi,
Question on Load/import command.
consider a sample table
create table table_name (
col1 timestamp not null default current timestamp,
col2 int,
col3 int,
col4 int,
primary key(col1) );
There is a file file.del containing data for col2,col3,col4. Data for
col1 is missing.

Is there a way I can use load/import command to get data into above
table from file? How would I insert timestamp values into col1?
Running DB2 Ver 7.2.0 on RedHat 8.0.

Any feedback is highly appreciated, thanks jay


What you have described is inconsistent and will not work, unless you
want to and can do a s-l-o-w load, one that is slow enough that the
time stamp will change between loading one row and the next! If you
remove the requirement that col1 be a primary key, the load command
would be simply:

load from <filename> of del modified by coldel, insert into
table_name(col2,col3,col4);

To add time-stamps later, you would do an UPDATE.

Here is what I get with the primary key requirement removed (as you can
see, all four rows were loaded before the timestamp changed):

db2 => select * from table_name;

COL1 COL2 COL3 COL4
-------------------------- ----------- ----------- -----------
2005-02-19-10.48.22.275928 11 12 13
2005-02-19-10.48.22.275928 21 22 23
2005-02-19-10.48.22.275928 31 32 33
2005-02-19-10.48.22.275928 41 42 43

4 record(s) selected.

:- N. Shamsundar
:- University of Houston

Here is a rather mean(!) trick:
CREATE FUNCTION bigliar() RETURNS TIMESTAMP
DETERMINISTIC -- evil laugh
NO EXTERNAL ACTION CONTAINS SQL
RETURN TIMESTAMP(generate_unique())
;
CREATE TABLE table_name (
col1 timestamp not null generated always as (bigliar()),
col2 int,
col3 int,
col4 int,
primary key(col1) );

You need DB2 UDB V8.2.
Prior to V8.2 you will need to use an external UDF.
After years of deliberation we concluded that customers have the right
to lie and DB2 has no business to prevent it.....

If you want to provide timestamps yourself you simply ALTER TABLE ...
ALTER COLUMN .. DROP EXPRESSION.
Adding an expression requires a detour through SET INTEGRITY OFF
and then SET INTEGRITY UNCHECKED IMMEIATE.

Oh.. and WHERE col1 = bigliar() would be a really bad idea.. In fact
don't mention bigliar() ever in any query...

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alex Hunsley | last post by:
I'm using a mysql monitor under cygwin (on win xp) to do a 'load data infile' to put some data into a mysql database (I'm using the xampp bundle).. My problem is that I have a four line CSV file...
3
by: Astra | last post by:
Hi All I'm really stuck on this one so would appreciate any help you can give. In essence, I have 1 SQL 2000 table with rows of data logging stock movement. To differenciate between a stock...
7
by: laurenq uantrell | last post by:
Is there any reason to have a row that is the PK/Identity and a row that is datatype Timestamp in the same table? Does this in any way help speeding up row updates? Thanks, lq
1
by: Uthuras | last post by:
Greetings, Machine : Pentium IV Os Windows 2000 server Product : DB2 UDB Release : 7.2 We are fail to load the following data file format into db2 database table that has long varchar...
2
by: Robert Fitzpatrick | last post by:
Does COPY require values for each column even though the database field is not set to NOT NULL? I did a COPY TO first to line up the data and then COPY FROM a tab delimited file. Here are the first...
3
by: stefaan.lhermitte | last post by:
Dear MySQL-ians, I perform a SELECT on my database, but it takes over a minute for every run. I have to run it over 10000 times (with different values in the WHERE), so it takes way too long. A...
1
by: dbagirltx | last post by:
We have done some testing with mixed and forgotten results. So I'm hoping that asking here can clarify some issues for us. Right now we do one weekly warm backup. Throughout the week there are...
9
by: Mohd Al Junaibi | last post by:
Hello all, my first post here...hope it goes well. I'm currently working on stored procedure where I translated some reporting language into T-SQL The logic: I have a group of tables...
1
by: Ultrak The DBA | last post by:
UDB Version 8.2 FP7 (r"DB2 v8.1.1.128", "s061108", "U810098", and FixPak "14".) 64 bit running on AIX 5.3. We were getting the SQL0668 error below so we put the status sql into the script to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.