I'm wondering if there is any possibility of creating Custom Table outside install or update script, and without using the query("CREATE TABLE statement"), in Magento 1.9+

1 Answer 1


The Magento way of creating tables in install scripts is not using raw SQL but the Zend API:

$table = $installer->getConnection()
    ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
        'identity'  => true,
        'unsigned'  => true,
        'nullable'  => false,
        'primary'   => true,
        ), 'ID')

More on the topic: http://inchoo.net/magento/magento-install-install-upgrade-data-and-data-upgrade-scripts/

You can do the same anywhere else if you replace $installer->getConnection() with Mage::getSingleton('core/resource')->getConnection('core_write');.

  • Many Thanks @fschmengler , I'm going to try creating a table using Controller's Action (at the BackEnd). Apr 12, 2016 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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