Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7950591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:19:19+00:00 2026-06-04T02:19:19+00:00

I have 30 tables in a database, all InnoDB. They have their structure. What

  • 0

I have 30 tables in a database, all InnoDB. They have their structure.

What I want to do is actually adding the bellow columns to EVERY table.

  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` text COLLATE utf8_unicode_ci NOT NULL,
 `description` text COLLATE utf8_unicode_ci NOT NULL,
 `categoryId` int(11) NOT NULL,
 `imageId` int(11) NOT NULL,
 `created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
 `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 `createdId` int(11) NOT NULL,
 `updatedId` int(11) NOT NULL,
 `allowedEmployeeIds` text COLLATE utf8_unicode_ci NOT NULL,

In a programming language (assume PHP) the normal approach is to create an abstract class, put all of the common variables there, and then inherit from it. What about MySQL? how should I do this?

For reasons coming from design, it’s not possible for me to create a commonData table and use foreign keys / join. Please note that I am writing the create statements from scratch, so there is no need for update.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:19:20+00:00Added an answer on June 4, 2026 at 2:19 am

    I’d think through this for a while — it’s complicated and will add a lit to what you’re trying to do. It’ll add a lot of work later.

    But if you really want to do this, the way to do it is not to put this in the table definition, but to create a script that can add these columns to a table.

    Something like:

    ALTER TABLE table_name
    ADD `id` int(11) NOT NULL AUTO_INCREMENT,
    ADD `name` text COLLATE utf8_unicode_ci NOT NULL,
    ADD `description` text COLLATE utf8_unicode_ci NOT NULL,
    ADD `categoryId` int(11) NOT NULL,
    ADD `imageId` int(11) NOT NULL,
    ADD `created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
    ADD `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    ADD `createdId` int(11) NOT NULL,
    ADD `updatedId` int(11) NOT NULL,
    ADD `allowedEmployeeIds` text COLLATE utf8_unicode_ci NOT NULL;
    

    Then simply execute this script for each table you have.

    If you want to write a script to do this flor all tables, use the command:

    SHOW TABLES;
    

    to find all the tables. Then loop through all the tables and execute the alter script on all the tables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 database tables, all of them have the same 5 columns. They
I have a java class containing all the columns of a database table as
Here's some background info. I have three MySQL tables (all InnoDB). The first table
I have a database ~800k records showing ticket purchases. All tables are InnoDB. The
All tables in my database always have an id (autoincrement), at column 0 regardless
I have a 5GB database, all tables are MyISAM. It runs into heavy load
I have a table in an Access 2007 database. All fields are of type
I have two database tables with the following structure: actions: action_id int(11) primary key
I have several databases in MySQL with InnoDB engine. All together they have around
I have a database, with several tables. The main table, called contacts , stores

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.