Solved

Where to store the queries for modification of table

Posted on 2016-11-15
4
87 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 27

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 16

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 32

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

726 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