Solved

Where to store the queries for modification of table

Posted on 2016-11-15
4
29 Views
Last Modified: 2016-11-21
Hi,
Where do i store the queries for modification of the table.
In my java project i have made a file called dump.sql which contains all the create table queries which were used to create tables.. what happens is sometimes say i need to add a new column or change the type of existing column i just store the new create table query and not the steps of queries i made to change the table.. I feel they should also be stored... What is the standard way or how you do it..
Do you store the in between queries that were used to made modification to the table or just the final queries ?

In case of storing them how do i store them... Should i just make a separate .sql file and put all these modification queries there ?

Thanks
0
Comment
Question by:Rohit Bajaj
4 Comments
 
LVL 26

Accepted Solution

by:
dpearson earned 250 total points
ID: 41889199
Should i just make a separate .sql file and put all these modification queries there ?

That's exactly how we do it.  We maintain a list of patch files - each of which contains the "ALTER TABLE" and similar statements that modify the database table schema.

We then apply those patch files to the live database (the one which contains data) and can also run them all in sequence to create a new empty database when testing.

Once you have that series of files, you can always generate the "CREATE TABLE" statements if you need them for some reason by just dumping the database again.

Doug
0
 
LVL 15

Assisted Solution

by:gurpsbassi
gurpsbassi earned 125 total points
ID: 41889212
Are you using any version management for the schema?

I've always used liquibase or flyway. It does the job nicely.
0
 
LVL 31

Expert Comment

by:awking00
ID: 41890313
What database?
0
 
LVL 5

Assisted Solution

by:kcm76
kcm76 earned 125 total points
ID: 41894272
you can store these files under a DBScripts folder in Source control - ex SVN with name of the file as DDL_Tablename.sql

you can keep appending the sqls for all changes made in sequence.

for ex:
-- 1) Create table
-- 2) Add constraints
-- 3) Alter table to add columns
and so on.

if you dont want to maintain in same file, You can also create sqls and maintain with Sl No in the name that will help you to identify the order and history of what has happened over a period of time

Hope this helps
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now