How to check the datatypes of the columns are same through shell scripting?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to check the datatypes of the columns are same through shell scripting?
# 1  
Old 04-04-2017
How to check the datatypes of the columns are same through shell scripting?

Hi,

We have a requirement like, to check the datatypes of columns against database.

After loading the sample data in to one of the database, need to compare the datatypes of the columns are matching with the provided files.

Is there a way that we can achieve through shell scripting.

We are using Netezza as database.

Any help/inputs are really appreciated.

Thanks in advance.
Samah
# 2  
Old 04-04-2017
Do you mean as an example:
You expect a date datatype. Does the date have to be valid?

Or do you simply want to make sure no number datatypes have problems?

To be honest I have worked with databases for a VERY long time, and the databases have always caught datatype mismatches. The requirement sounds more like really uniformed management decision.

In any case, please give us some simple examples of what you need to check.
# 3  
Old 04-04-2017
Jim,

Thanks for the quick response!

Actually once the sample data has loaded, i will be performing some manual QA checks to make sure the data received as expected. For example, duplicates check,any column has null values,...etc.,

One of the validation check, i need to make sure the datatypes of the all columns of a table are also matching against database based on data feed requirement document.

Thanks.
# 4  
Old 04-04-2017
You can normally define a few things to help you, such as unique constraints and defining the column as not accepting nulls.

It then depends on your loader if it pushes in the records it can and reports the anomalies, or if it just fails altogether at the start or with partial data loaded.



Robin
# 5  
Old 04-04-2017
What Robin is saying - set the database metadata (column descriptions) to values that actually enforce datatyping, like DATE, NUMBER(5). When you insert data, the db will check to be sure data is correct in terms of typing. Instead of you having to do it manually later on. There are constraints that you use as well when you first create your new table - like NOT NULL, UNIQUE (for keys), and dependancy - key in child table has to match existing column value in parent table.

If you allow weak datatyping, like setting a column to allow any text, then anything can and will be inserted into that column. And you have a mess to clean up.
# 6  
Old 04-04-2017
Thanks Robin and Jim.

My task is to check whether the datatypes are correct after the ETL load.

I got your point but how to automate the below step through shell scripting.

"One of the validation check, i need to make sure the datatypes of the all columns of a table are also matching against database based on data feed requirement document."

Would it be possible to give an example for this?

For example: I am using the below datatypes.
Code:
INTEGER (9)
CHARACTER (100)
DATE (yyyy-mm-dd)
NUMBER (17,4)

Thanks.

Last edited by rbatte1; 04-04-2017 at 11:37 AM.. Reason: Added CODE tags for clarity
# 7  
Old 04-04-2017
If you describe the table and compare it to your document, would that do what you need? To automate that, you would need to get the document into a simple format that matches the structure displayed when you describe the table.


I'm still not sure on your real needs or if this is management paranoia.

Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To check if the JAVA Program is successfully executed in sh shell scripting

Hi , I have written a shell script to call a java program say load_id.sh .This sh script indeed is executed implicitly in other sh script which calls 2 more sh scripts one by one. I need to check if the load_id.sh (which calls java program) is executed successfully only then continue with... (1 Reply)
Discussion started by: preema
1 Replies

2. Shell Programming and Scripting

Shell scripting - need to arrange the columns from multiple file into a single file

Hi friends please help me on below, i have 5 files like below file1 is x 10 y 20 z 15 file2 is x 100 z 245 file3 is y 78 z 23 file4 is x 100 (3 Replies)
Discussion started by: siva kumar
3 Replies

3. Shell Programming and Scripting

Validating a datafile with the datatypes

I have two input files 1)datafile 2)metadata file. I have a metadata file like: field1datatypeformat1number2string3dateyy-mm-dd I have a data file like: 1234abc12-8-16 xyz234512-9-163456acd14-08-12 In the first row there is no correction as everything is inline with the metadata.... (3 Replies)
Discussion started by: bikky6
3 Replies

4. Shell Programming and Scripting

Transposing rows and columns (pivoting) using shell scripting

Here is the contents of an input file. A,1,2,3,4 10,aaa,bbb,ccc,ddd 11,eee,fff,ggg,hhh 12,iii,jjj,lll,mmm 13,nnn,ooo,ppp I wanted the output to be A 10 1 aaa 10 2 bbb 10 3 ccc 10 4 ddd 11 1 eee 11 2 fff 11 3 ggg 11 4 hhh ..... and so on How to do it in ksh... (9 Replies)
Discussion started by: ksatish89
9 Replies

5. Shell Programming and Scripting

C shell scripting, check if link exists on remote servers

Hi, I'm new to C Shell programming. I'm trying to check if a sym link exists on remote server if not send email. I'm not having much luck. Can anyone help? Here is what I have written but it doesn't work. It tells me that my variable was not defined. Here is part of the script, the second... (0 Replies)
Discussion started by: CDi
0 Replies

6. Shell Programming and Scripting

Scripting columns

I've got the following data in a file - basically hundred of passes. Pass Id : PASSID1 Pass Name : 7 day pass 10 Gb Pass Group : uk Short Name : pmbbrh2 type : restrict Validity ... (7 Replies)
Discussion started by: jeffersno1
7 Replies

7. Shell Programming and Scripting

New to Shell scripting: Can you check it?

I am trying to write a script to get all the html files under a source directory and and for each html file, run a program with html file as an argument. This program generates an output which I need to save as htmlfilename.txt ( right now i was trying to print it on the command line) ... (11 Replies)
Discussion started by: sapient
11 Replies

8. Solaris

How to check the file existence using shell scripting in Solaris-10

Hi, I have a script which will check the fiel existence, the lines are as below if !(test -d ./data) then mkdir data fi In the first line error occurs as below generatelicense.sh: syntax error at line 2: `!' unexpected Where as this script works fine in linux OS. How to solve... (2 Replies)
Discussion started by: krevathi1912
2 Replies

9. UNIX for Dummies Questions & Answers

How to check process/cpu utilisation thru unix shell scripting

Dear Champs, Can anybody help me out to write a shell script , which will check whether the process is running , if running then divide the process into 2 so that next var it can take process parallel . Let ps -ef | grep a.sh => shows running note a.sh will take a process of next... (0 Replies)
Discussion started by: manas_ranjan
0 Replies

10. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies
Login or Register to Ask a Question