Mysql, help to understand data export

Asked

Viewed 89 times

2

In the old days when I was exporting a database I was like this:

CREATE TABLE `config` (
  `ID_Config` int(1) NOT NULL AUTO_INCREMENT,
  `nome_site` varchar(255) DEFAULT NULL,
  `thema` char(50) NOT NULL,
  PRIMARY KEY (`ID_Config`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

The auto_incremente and Primary key were directly in the CREATE command.

Now when I export it gets like this:

CREATE TABLE IF NOT EXISTS `config` (
  `Id` int(11) NOT NULL,
  `versao` varchar(10) NOT NULL,
  `sitemodelo` varchar(4) NOT NULL,
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 ;

--
-- Indexes for table `config`
--
ALTER TABLE `config`
 ADD PRIMARY KEY (`Id`);

--
-- AUTO_INCREMENT for table `config`
--
ALTER TABLE `config`
MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;

A class I found on the internet class.leitor_sql.php does not read the rest of the commands, only what is inside the CREATE.

Question: There is a way to change mysql export configuration in phpMyAdmin?

Thank you.

  • You know what was changed for it to start generating different export?

  • @Ricardo I believe it’s the version, because it changed on its own.

2 answers

1

What happens is that the second form generates a consistency of data.

The command CREATE TABLE IF NOT EXISTS create a new table if there is no.

So, at this point you can create a data conflict if the auto_increment of the existing table is different from the table you are importing.

Therefore there is the change of the table schema then separately from the command CREATE.

Use an SQL command importer that supports multiple queries recognition. Phpmyadmin itself, for example.

1

The problem is in the export template. Phpmyadmin offers you different types of exports, such as __DB__ and __TABLE__, for example. Each template brings a different format. The second format is for __DB__, if I’m not mistaken, because he brings first all the tables and then all the records. If in the table definition it brought auto_increment preconfigured, the inserts that would come at the end of the file would not start with the number 1.

To get the first template, I believe you should export only the table structure and not the entire base.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.