I have a CSV file where:
column1 has names
column2 is age
For example:
column1, column2
Maria., 24
Sunio., 65
Morris., 45
There 100 fields.
I want to replace column1 values with NULL:
Expected Output:
column1, column2
NULL, 24
NULL, 65
NULL, 45
How can I achieve this?
I have tried with update record....but not successful
With update record processor you are able to update any column to any value you want.
Here is an example:
[
You should consider there is no such thing as null value in csv, if you want to treat some value as null you should specify that on CSVReader or CSVRecordSetWriter as follow:
Related
I have a situation where in I need to take the values from table column which has data based on one of the column in same table.
There are two column values like that which is required to compare with another table.
Scenario:
Column 1 query:
SELECT text_value
FROM WF_ITEM_ATTRIBUTE_VALUES
WHERE name LIKE 'ORDER_ID' --AND number_value IS NOT NULL
AND Item_type LIKE 'ABC'
this query returns 14 unique records
Column 2 query:
SELECT number_value
FROM WF_ITEM_ATTRIBUTE_VALUES
WHERE name LIKE 'Source_ID' --AND number_value IS NOT NULL
AND Item_type LIKE 'ABC'
this also returns 14 records
and order_id of column 1 query is associated with source_id of column 2 query using this two column values i want to compare 14 records combined order_id, source_id with another table column i.e. Sales_tbl
columns sal_order_id, sal_source_id
Sample Data from WF_ITEM_ATTRIBUTE_VALUES:
Note: same data in the sales_tbl table but order_id is sal_order_id and sal_source_id
Order_id
204994 205000 205348 198517 198176 196856 204225 205348 203510 206528 196886 198971 194076 197940
Source_id
92262138 92261783 92262005 92262615 92374992 92375051 92374948 92375000 92375011 92336793 92374960 92691360 92695445 92695880
Desired O/p based on comparison:
Please help me in writing the query
The data beyond 32762 characters is getting truncated when I am loading the data in my BigSQL table. My table definition is as below :
CREATE hadoop TABLE schema_name.table_name
(
column1 VARCHAR(50),
column2 INTEGER,
column3 STRING,
loaddate TIMESTAMP
)
STORED AS PARQUET;
The for column3 is getting truncated.
Is there a way to store the full data?
Maybe the CLOB is the answer you're looking for
I'm trying to parse line into columns in control file.
I get "Field in data file exceeds maximum length"
My control file:
OPTIONS (
ERRORS = 1,
DIRECT=TRUE,
LOAD=10
)
load data
APPEND
into table table_1
fields terminated by "#x000A"
(
Column0 BOUNDFILLER,
Column1 "SUBSTR(:Column0, 1, 10)"
)
Table:
create table table_1 (
Column0 VARCHAR2(2000)
Column1 VARCHAR2(124)
);
It looks like it happens because length of each row is more that 2000 but I checked the file and it's less that 1000.
So why I get this error?
The error is here. Column0 BOUNDFILLER, this line is equal Column0 BOUNDFILLER char(255),.
char(255) is default value.
You are trying to put 1000 into variable with space only for 255.
Solution is Column0 BOUNDFILLER char(2000) ,
I have table as,
create table names
(name string,insert_time timestamp)
row format delimited
fields terminated by ','
stored as textfile;
select * from names;
OK
abc 2017-05-06 10:11:30
abc 2017-05-07 11:15:40
pqr 2017-05-06 12:11:10
I want to fetch only latest inserted data.
O/P should be as follows,
abc 2017-05-07 11:15:40
pqr 2017-05-06 12:11:10
Please Guide how to get this.
Use order by and limit:
SELECT * FROM names ORDER BY insert_time DESC LIMIT 2
order by desc will sort the records by timestamp in decreasing order, limit n will return only the first n records.
I have a requirement to find all not-null columns in a table. For example, my table is the below one
Lets say, Column1, Column2 and Column3 have not-null constraints and Column4, Column5 and Column6 are of nullable types. Is there any query in Oracle that list the column names that are of not-null types, ie I need to get the column names Column1, Column2 and Column3.
DESIRED OUTPUT
Column1
Column2
Column3
I know there should be a simple way to achieve this, but am new to Oracle. Any help would be highly appreciated.
You can query the all_tab_columns table:
select column_name
from all_tab_columns
where table_name = 'TABLE1'
and nullable = 'N';
I know there should be a simple way to achieve this, but am new to Oracle.
Well, online documentation is exactly what you need to look into.
Depending on the privilege, you need to look into [DBA|USER|ALL]_TAB_COLUMNS.
ALL_TAB_COLUMNS
Column Datatype Description
NULLABLE VARCHAR2(1) Indicates whether a column allows NULLs.
The value is N if there is a NOT NULL constraint
on the column or if the column is part of a PRIMARY KEY.
The constraint should be in an ENABLE VALIDATE state.
So, per the documentation, you need to use the filter:
NULLABLE = 'N'