?
Solved

Where to store the queries for modification of table

Posted on 2016-11-15
4
Medium Priority
?
98 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 28

Accepted Solution

by:
dpearson earned 1000 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 500 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 500 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

Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
A solution for Fortify Path Manipulation.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

801 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