converting sybase datetime format to oracle timestamp - oracle

I am getting bellow datetime format from sybase DB
2015-08-12T11:49:50.196+01:00
and i need to insert this value into oracle database column of type TIMESTAMP(6).
i am not able to specify the correct format to insert the above datetime in to Timestamp column in oracle.
can any one help me in this.
thanks in advance.

Are you sure that you don't want to store time zone information (thus type TIMESTAMP(6) WITH TIME ZONE)?
CREATE TABLE timestamp (value TIMESTAMP(6));
INSERT INTO timestamp VALUES (TO_TIMESTAMP_TZ('2015-08-12T11:49:50.196+01:00', 'YYYY-MM-DD"T"HH24:MI:SS.FF3 TZH:TZM'));

Related

CurrentTime() generated from Pig showing as NULL in Hive Datetime column

In Pig script I have generated datetime column with its value as CurrentTime().
While reading the data from Hive Table for the output generated by PigScript, it shows as NULL.
Is there any way that I can load the current datetime column from PIG to show in Hive Table?
The data in the file looks like 2020-07-24T14:38:26.748-04:00 and in the hive table the column is of timestamp datatype
Hive timestamp should be in 'yyyy-MM-dd HH:mm:ss.SSS' format (without T and timezone -04:00)
1.Define Hive column as STRING
2.Transfom string to format compatible with Hive timestamp
If you do not need milliseconds:
--use your string column instead of literal
from_unixtime(unix_timestamp('2020-07-24T14:38:26.748-04:00',"yyyy-MM-dd'T'HH:mm:ss.SSSX"))
Returns:
2020-07-24 18:38:26
If you need milliseconds then additionally extract milliseconds and concatenate with transformed timestamp:
select concat(from_unixtime(unix_timestamp('2020-07-24T14:38:26.748-04:00',"yyyy-MM-dd'T'HH:mm:ss.SSSX")),
'.',regexp_extract('2020-07-24T14:38:26.748-04:00','\\.(\\d{3})',1))
Result:
2020-07-24 18:38:26.748
Both results are compatible with Hive timestamp and if necessary can be cast explicitly to Timestamp type using CAST(str as timestamp) function, though comparing these strings with timestamps or inserting into timestamp works without explicit cast.
Alternatively you can format timestamp in Pig to be 'yyyy-MM-dd HH:mm:ss.SSS' I do not have Pig and can not check how ToString works.
Also for LazySimpleSerDe, alternative timestamp formats can be supported by providing the format to the SerDe property "timestamp.formats" (as of release 1.2.0 with HIVE-9298). Try "yyyy-MM-dd'T'HH:mm:ss.SSSX"

Does oracle store transaction date of data?

Im currently using oracle 11g. I had extracted data from the schema once at a specific date to do some cleansing process. Suppose that now i would want to extract again but only with new/updated data from the last date i extracted, is there anyway i could get it? unfortunately these data does not have any column that store last edited date.
i was wondering if Oracle would automatically store that type of info that i could check? perhaps any transaction log?
Thanks,
A Physal
One way would be to enable flashback and then you can do:
SELECT * FROM table1
MINUS
SELECT * FROM table1 AS OF TIMESTAMP TIMESTAMP '2018-01-01 00:00:00.000';
To get all the rows changed since 2018-01-01.

Add constraint to already existing column to store Record Created Timestamp

I have a Existing column called CREATED DATE whose data type is "Date". I am trying to add a constraint to this CREATED DATE Column which will store "Record created time stamp". I have a following query in place but its working out. Any suggestions will be helpful.
ALTER TABLE CONTAINER_SCAN_LOG
MODIFY (CREATED_DATE DEFAULT (sysdate());
what is the error exactly ? what is the default date? anyway try to remove the parenthesis
ALTER TABLE ex_employee
MODIFY START_TIME DEFAULT (sysdate);
use timestamp instead of date
alter table t add (created_datetime timestamp default systimestamp)
or modify existing created_date to be of timestamp datatype and systimestamp default

java timestamp with timezone to store in ORACLE DB

I need to insert Timestamp with Timezone in Oracle DB using java JDBC. I have a timestamp in one variable and need to append Timezone, like Europe/Paris, to my timestamp and store it in the DB which has a column of datatype Timestamp with Timezone.
How can I achieve that?

Informatica Date/Time Conversion

in one of the requirment informatica fetching data from flat file as source file and insert records into a temporary table temp of DB2 database. Flat file has one column as datetime datatype (YYYY/MM/DD HH:MM:SS). However, informatica fetching this column as string datatype (Since Informatica date format is different from this column & DB2). So before loading into temp table of DB2 database, I need to convert back this column into Datetime format.
With Expresion transformation, I can do this but I dont know how? To_date conversion function (TO_DATE(FIELD, 'YYYY/MM/DD HH:MM:SS')) is there but it will take care of date only (YYYY/MM/DD). Its not taking care of time (HH:MM:SS) and because of this records are not inserting into temp table.
How can I convert datetime from String datatype to DB2 datetime format (YYYY/MM/DD HH:MM:SS)?
You tried to use the month format string (i.e. MM) for the minutes part of the date.
You need to use MI:
TO_DATE(FIELD, 'YYYY/MM/DD HH:MI:SS')

Resources