I have a script which takes a database and generate export like query for the database as a backup. I need this script for a purpose. My php code is:
mysql_query("SHOW CREATE TABLE `myTable`");
there are 17 tables in the database. I am running a for loop for all 17 tables. I get the create table query with foreign key which I do not want. It returns like-
CREATE TABLE `customers` (
`person_id` int(10) NOT NULL,
`account_number` varchar(255) DEFAULT NULL,
`taxable` int(1) NOT NULL DEFAULT '1',
`deleted` int(1) NOT NULL DEFAULT '0',
UNIQUE KEY `account_number` (`account_number`),
KEY `person_id` (`person_id`),
CONSTRAINT `customers_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `people` (`person_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
because of the foreign key, it gets an error while running queries for creating tables. is there any way to get the sql without foreign key? like-
CREATE TABLE IF NOT EXISTS `customers` (
`person_id` int(10) NOT NULL,
`account_number` varchar(255) DEFAULT NULL,
`taxable` int(1) NOT NULL DEFAULT '1',
`deleted` int(1) NOT NULL DEFAULT '0',
UNIQUE KEY `account_number` (`account_number`),
KEY `person_id` (`person_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;