Muhamad Gafar
Muhamad Gafar

Reputation: 409

What is the correct way of storing .sql type files in a database?

I am working in a system which gets reloaded frequently. When the system is reloaded a lot of files can be deleted or changed back to a previous stable build version (it's a dev environment). The only thing that doesn't get reloaded is a database.

I have been tasked with inserting and deleting .sql scripts into the environments so that if required someone can run them at a given time. Usually 2 weeks after the files have been added to the system.

Initially I had thought of creating a directory to keep the files, and make a table where one of the columns keeps the path to these .sql files. This would allow for someone to query the database and using the path they could execute a desired script. The problem is the environment constantly reloading which could result in losing files.

Am I correct in assuming that the correct way to approach this is to use BLOB datatype to store the .sql files? The database isn't reloaded so no files would be lost. I am new to SQL and I'm unsure what is the correct approach to this. Would Varchar also work? Is one datatype more efficient than the other?

Upvotes: 0

Views: 152

Answers (1)

Horatiu Jeflea
Horatiu Jeflea

Reputation: 7424

I wouldn't put SQL scripts in a SQL database, it doesn't feel right. Sql Scripts usually go in a git repo, in order to be versioned and have better visibility.

Upvotes: 1

Related Questions