John Smith
John Smith

Reputation: 6207

How to detect if a database structure changed? (not content!)

In my php script I want to check if a structure of database table has changed. The DESCRIBE TABLE wont provide enough informations, because it ignores the foreign keys. The SHOW CREATE TABLE is too much, because auto incremental value also appears here.

Upvotes: 2

Views: 112

Answers (1)

Karoly Horvath
Karoly Horvath

Reputation: 96326

The SHOW CREATE TABLE is too much, because auto incremental value also appears here.

Just filter out the auto incremental value with a regexp.

preg_replace('/ AUTO_INCREMENT=[0-9]+ /', ' ', $sql);

Upvotes: 5

Related Questions