I am using MySQL to capture snapshots of my data everyday, so I need to create multiple tables with the same columns.
my_foobar_table_20170125
my_foobar_table_20170126
my_foobar_table_20170127
What's the easiest way to create the tables? Would it be with a table schema file? Or, with a create table query?
I am leaning toward using a table schema file if that is possible. As it seems cleaner than a sql query to create the table.
I have googled around, and surprisingly there is no clear answer on this. In fact, it's not even obvious what exactly is a "table schema file", or how to generate this from mysql workbench, or use the schema file to create the table.
Definitely create a table .sql file and load it into MySQL then log in. Manually making it each time is a ton of work and this allows you to also customize each table if needed, and to use drop database and to refresh easily as well.
CREATE DATABASE databasename;
USE database;
CREATE TABLE tableofthings (
ID INT NOT NULL AUTO_INCREMENT,
otherdatastring VARCHAR(50)...
PRIMARY KEY (ID)
);
...then put other tables below...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.