-1

I am running syslog-ng server in Ubuntu. When it receives logs from the local routers/devices, it insert records in LOGS DB How can I automate things so that mysql should create tables according to the current date and insert record into it.

Example if today is 9-11-2018, it should dynamically create table in this DB with 9-11-2018 name and insert record in this table, when date changes, it should auto create 10-11-2018 and insert records in it.

or like year > month > date Is this possible ?

  • 1
    Just curious why you want a separate table created for each day? – Dave Nov 9 '18 at 11:09
  • 1
    In most cases runtime DDL means design error. How can I automate things so that mysql should create tables according to the current date and insert record into it. Stored procedure with dynamic SQL (prepared statement). – Akina Nov 9 '18 at 11:13
0

There is rarely a valid reason to build multiple tables with the same schema.

If your goal is to have time-oriented data and you intend to purge data after some date, then a PARTITIONed table is probably the way to go. I recommend no more than 50 partitions, so you may want weekly instead of daily partitions.

More on such Partitioning is here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.