Title: Load sql file into database from plugin
Last modified: December 20, 2019

---

# Load sql file into database from plugin

 *  Resolved [francescjp](https://wordpress.org/support/users/francescjp/)
 * (@francescjp)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/load-sql-file-into-database-from-plugin/)
 * Hello:
 * I am developing a wordpress plugin. I want that when it is being installed I 
   am able to create several tables into wordpress database with sql file. I want
   to loadfile to database in order to create the tables. If I use text through 
   php the tables are created.
 * Thank you very muach.
 * Francesc

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/load-sql-file-into-database-from-plugin/#post-12259290)
 * Why utilize a SQL file to create tables? Why not keep the SQL in a PHP file as
   a series of `$wpdb->query( $wpdb->prepare( 'CREATE TABLE IF NOT EXISTS...' ));`
   lines executed upon activation?
 * In any case, you’d need to get the SQL file contents, parse out the individual
   queries and execute them in code similar to the above.
 *  Thread Starter [francescjp](https://wordpress.org/support/users/francescjp/)
 * (@francescjp)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/load-sql-file-into-database-from-plugin/#post-12568754)
 * Thank you very much for your help.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Load sql file into database from plugin’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 2 participants
 * Last reply from: [francescjp](https://wordpress.org/support/users/francescjp/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/load-sql-file-into-database-from-plugin/#post-12568754)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
