Solved

Where to store the queries for modification of table

Posted on 2016-11-15
4
77 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Eclipse with gitlab 1 163
hibernate jars 4 59
ejb wildfly example 2 74
Java: anonymous class 4 38
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

733 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