Sponsored Content
Full Discussion: Extract hive table structure
Top Forums Shell Programming and Scripting Extract hive table structure Post 303011350 by rohit_shinez on Wednesday 17th of January 2018 04:32:40 AM
Old 01-17-2018
Hi,

i am trying to extract the tables from the database named as schema and get the create table structure

Code:
#!/bin/bash
rm -f tableNames.txt
rm -f HiveTableDDL.txt
hive -e "use $1; show tables;" > tableNames.txt  
wait
cat tableNames.txt |while read LINE
   do
   hive -e "use $1;show create table $LINE" >>table.hql
   echo  -e ";\n" >> table.hql
   done
rm -f tableNames.txt
echo "Table DDL generated"

sh table.sh schema

I would require to extract only till below

Code:
create table hive_table(id number,age number);

because show create will give me table properties like below

Code:
create table hive_table(id number,age number)
OUTPUTFORMAT
  'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
LOCATION  'hdfs:/path/'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract Table from PDF

Hi Guys! I want to extract table from PDF in HTML. Can we do this using Shell script....??. Please provide me your suggestions. Any help will be highly appreciated. Thanks! (2 Replies)
Discussion started by: parshant_bvcoe
2 Replies

2. Shell Programming and Scripting

How to create a C structure using table description.

There is table 'DEPT' in the database with the following desciption: Name Null? Type ------- -------- ------------------------ DEPTNO NOT NULL NUMBER(2) DNAME NULL VARCHAR2(14) LOC NULL VARCHAR2(13) Using shell script, I need to create a structure for the... (2 Replies)
Discussion started by: ehari
2 Replies

3. Shell Programming and Scripting

Extract table name from DDL

How can I extract table name from the different DDL statement like ALTER TABLE CREATE TABLE etc Basically I have to parse thr the any of the DDL statement and verify if that DDL statement is implemented by DBA or not. how can i do this efficiently in Kornshell scripting. (2 Replies)
Discussion started by: gayathree
2 Replies

4. Shell Programming and Scripting

Extract files from tar ball without directory structure

Hi, I have tar filw which has multiple directories which contain files. When i extract using tar -xf the directory structure also get extracted. I require only files and not directory structures as there will be overhead of moving the files again. So i searched here and got a solution but... (4 Replies)
Discussion started by: chetan.c
4 Replies

5. UNIX and Linux Applications

Help in copying table structure to another table with constraints in Oracle

hi, i need to copy one table with data into another table, right now am using create table table1 as select * from table2 i want the constraints of table1 to be copied to table2 also , can anyone give me some solution to copy the constraints also, now am using oracle 10.2.0.3.0... (1 Reply)
Discussion started by: senkerth
1 Replies

6. UNIX for Dummies Questions & Answers

Extract table from an HTML file

I want to extract a table from an HTML file. the table starts with <table class="tableinfo" and ends with next closing table tag </table> how can I do this with awk/sed... ---------- Post updated at 04:34 PM ---------- Previous update was at 04:28 PM ---------- also I want to... (4 Replies)
Discussion started by: koutroul
4 Replies

7. Shell Programming and Scripting

How to export hive table data to a file on local UNIX?

Hi All , I am stuck on the below situation.I have a table called "test" which are created on hive.I need to export the data from hive to a file(test.txt) on local unix system.I have tried the below command ,but its giving the exception . hive -e "select * from test " > /home/user/test.txt ; ... (1 Reply)
Discussion started by: STCET22
1 Replies

8. Shell Programming and Scripting

Extract table from file

I need to sort out table in a file to a format below: Input: this is a test example Cat Bee Dat 1 2 3 more Example date data Bet Cla Blaa Dat A 6 T data.. Output: this is a test (10 Replies)
Discussion started by: aydj
10 Replies

9. Shell Programming and Scripting

JSON structure to table form in awk, bash

Hello guys, I want to parse a JSON file in order to get the data in a table form. My JSON file is like this: { "document":{ "page": }, { "column": } ] }, { ... (6 Replies)
Discussion started by: Gescad
6 Replies

10. UNIX for Beginners Questions & Answers

Shell Script to read hive table and send email

HI Team, I am working on reading hive table and send email in email body using shell script, can you please help on fixing the errors: I have 6 columns in my hive table and trying to send the email in the mail body. below script: #!/bin/bash hive -e 'SELECT count(*) from db.table' >... (4 Replies)
Discussion started by: Mi4304
4 Replies
DB2_FOREIGN_KEYS(3)							 1						       DB2_FOREIGN_KEYS(3)

db2_foreign_keys - Returns a result set listing the foreign keys for a table

SYNOPSIS
resource db2_foreign_keys (resource $connection, string $qualifier, string $schema, string $table-name) DESCRIPTION
Returns a result set listing the foreign keys for a table. PARAMETERS
o $connection - A valid connection to an IBM DB2, Cloudscape, or Apache Derby database. o $qualifier - A qualifier for DB2 databases running on OS/390 or z/OS servers. For other databases, pass NULL or an empty string. o $schema - The schema which contains the tables. If $schema is NULL, db2_foreign_keys(3) matches the schema for the current connection. o $table-name - The name of the table. RETURN VALUES
Returns a statement resource with a result set containing rows describing the foreign keys for the specified table. The result set is com- posed of the following columns: +--------------+---------------------------------------------------+ | Column name | | | | | | | Description | | | | +--------------+---------------------------------------------------+ | PKTABLE_CAT | | | | | | | Name of the catalog for the table containing the | | | primary key. The value is NULL if this table does | | | not have catalogs. | | | | |PKTABLE_SCHEM | | | | | | | Name of the schema for the table containing the | | | primary key. | | | | |PKTABLE_NAME | | | | | | | Name of the table containing the primary key. | | | | |PKCOLUMN_NAME | | | | | | | Name of the column containing the primary key. | | | | | FKTABLE_CAT | | | | | | | Name of the catalog for the table containing the | | | foreign key. The value is NULL if this table does | | | not have catalogs. | | | | |FKTABLE_SCHEM | | | | | | | Name of the schema for the table containing the | | | foreign key. | | | | |FKTABLE_NAME | | | | | | | Name of the table containing the foreign key. | | | | |FKCOLUMN_NAME | | | | | | | Name of the column containing the foreign key. | | | | | KEY_SEQ | | | | | | | 1-indexed position of the column in the key. | | | | | UPDATE_RULE | | | | | | | Integer value representing the action applied to | | | the foreign key when the SQL operation is UPDATE. | | | | | DELETE_RULE | | | | | | | Integer value representing the action applied to | | | the foreign key when the SQL operation is DELETE. | | | | | FK_NAME | | | | | | | The name of the foreign key. | | | | | PK_NAME | | | | | | | The name of the primary key. | | | | |DEFERRABILITY | | | | | | | An integer value representing whether the for- | | | eign key deferrability is SQL_INITIALLY_DEFERRED, | | | SQL_INITIALLY_IMMEDIATE, or SQL_NOT_DEFERRABLE. | | | | +--------------+---------------------------------------------------+ SEE ALSO
db2_column_privileges(3), db2_columns(3), db2_primary_keys(3), db2_procedure_columns(3), db2_procedures(3), db2_special_columns(3), db2_statistics(3), db2_table_privileges(3), db2_tables(3). PHP Documentation Group DB2_FOREIGN_KEYS(3)
All times are GMT -4. The time now is 04:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy