0

I want to print table name once and associated column name for the table

I have tried the solution from

Search Sqlite Database - All Tables and Columns

but it prints table and column name many times depending on how many rows in the table

I would like output like:

table_name column_name
table_name column_name
table_name column_name
table_name column_name
table_name column_name
table_one_name column_name
table_one_name column_name
table_one_name column_name
table_one_name column_name
table_one_name column_name
kuro
  • 3,214
  • 3
  • 15
  • 31
  • 1
    You can get the table names from the link you provided, and the column names from [this question](https://stackoverflow.com/questions/7831371/is-there-a-way-to-get-a-list-of-column-names-in-sqlite). – glibdud May 20 '19 at 12:44
  • It still prints tables name and column name many times – Shuvo Barman May 20 '19 at 14:08
  • 1
    You'll need to provide a reproducible example. A small sample table and the code that produces the problem (be sure to verify that it does!), and a description of the output it produces and the output that is desired. – glibdud May 20 '19 at 14:22

1 Answers1

0

Whilst your question isn't very clear, I think this answer addresses your question well. Following that solution (slightly simplified) with a couple of example tables,

sqlite> create table t1 ( id int, name varchar(50) );
sqlite> create table t2 ( tel char(20), status varchar(5) );
sqlite> .mode column
sqlite> SELECT  m.name as table_name, p.name FROM sqlite_master AS m
   ...> JOIN pragma_table_info(m.name) AS p;
t1          id         
t1          name       
t2          tel        
t2          status     
sqlite> 
Andrew Richards
  • 1,392
  • 11
  • 18