0

I have 200 tab delimited files which I want to load up in MySQL database.Is there any way to automate create table command for creating the schema for 200 tables ,and loading up those 200 tables automatically?

The thing is I would have to run the create table query and loading tables 200 times each.so any way to automate it.

Rgeek
  • 419
  • 1
  • 9
  • 23
  • You'd have to know the datatypes for each of the columns, otherwise, how will you know how to create the tables? I don't think a tab-delimited file is going to have that info. – dcp Feb 28 '14 at 21:51
  • Is there any way to run the create table command which has the datatypes of the columns,only once for all 200 tables? – Rgeek Feb 28 '14 at 21:55
  • Duplicate of: https://stackoverflow.com/questions/3280006/duplicating-a-mysql-table-indexes-and-data – Bishwas Mishra Feb 15 '18 at 07:23

1 Answers1

0

The create table command creates one table. You can run 200 create tables in one sql script, but the create table schema would have to be there for each table.

The only way you could do multiple create tables is if all your tables were exactly the same. You could use a FOR LOOP to run the create table sql as many times as you want. The only thing is, if you have more than one table that is exactly the same, you have other problems. So the answer is no.

There are various software that can import your tab delimited files and create the tables for you, but you will still have import 200 times.

On the plus side, you only have to import them once. At that point you can easily export all the tables to a single sql file. You will now be at a single import of your tables for the future.

Master Coder
  • 79
  • 2
  • 3