How to extract data from an existing postgresql using liquibase changeset? - liquibase

I want to copy all data from QA DB to DEV DB using liquibase. I'm able to generate changeset which has only the DDL. But I want to generate the DML against QA db so that I can apply those changesets to DEV db in order to copy all data from QA DB to DEV DB.
Any help or direction would be greatly appreciated.

Related

Copy Database from server to local DB (I need copy only structure, without data)

I have a one problem. I have a database(MSSQL) on some server. I need copy this DB on my local DB. But! This DB is huge 7gb. I don't need data from this DB. I need just copy structure of this DB (What I mean about structure - all DB, all tables, connections, etc. (!!!But I don't need a data from this tables)). How I understand it - It will clean DB with the same structure.
I have no idea how implement it. I read what I can do it using PowerShell, Git and SQL manager. But i didn't find example. Could you tell me something about it?
Right click on your Database => Tasks => Generate Scripts
Screenshots shows this on a System Database. Don't do this on system databases.
Select the Tables / Views / Stored Procedures you want.
Change the scripting options depending on your preferences/requirements.
Generate the script
If you use MS SQL Server Management Studio, you can right-click on the tables you want to have in your other db -> Generate Script for -> Create -> and then choose one opion.
Only drawback is, that you have to do that for every table individually.

SAP PowerDesigner - alter model with SQL

I have a SQL script which fixes/alters the production DB schema (deployed from current PDM).
I need to mirror the same changes to the current PDM. Is there a way to run the same SQL script somewhere within the PowerDesigner so the PDM updates exactly the same instead of doing it manually step-by-step?

Generate changeLog for single sql files with liquibase

I have a huge database with many SQL files. Is there any way to generate a changelog for single SQL files and not for the whole database? I have stored some SQL files local on my hard drive and use liquibase via command line. If there is no way to do that with local SQL files, is there a way to generate a changelog for single tables of my database?
What you are looking for is not possible. A database does not remember the SQL that was executed to get the database into a certain state. Here is a real simple example. Say that you first run some SQL to create a table with two columns 'name' and 'id'. Then you run some more sql to add a third column 'active'. The database does not remember that two separate operations were run to get into that state. When Liquibase generates a changelog for that database, it basically has to ask the database 'what is the current state of things?' and so it would have a changeset that creates the table with all three columns.
It is possible to have liquibase generate smaller changelog files, but you should probably take a step back and ask yourself why you want to do that.

How to backup script for subset of tables in SQL Express DB

I have developed a SQL Express database. I need to backup all but one table in that database in an automated way. I was thinking i could write a SQL script to do this, trigger it using sqlcmd from a batch file but not sure how to write that SQL script.
I was also thinking, if nothing else possible, i could create a second db that has the tables i want to backup then i write a script that copys data 'into' the second db and then do a auto backup of that entire db. This has the disadvantage of having a procrastinated unpacking of that backup when wanting to use it - its not a small install script.
Is this a possibility, is it the only option or is there tools for SQL Express to do this?
There is no option to exclude just one table while backing up .Few things i could think of
1.Right click database ->Tasks ->generate scripts ->exclude the table you want and choose to save the script and run this every time
2.you could also choose Export option,but since you are using SQL Express,you wont have the option to save this package
Keep the large table in a different database and just backup the original database. You can still use the large table even in a different database, i.e.
SELECT *
FROM MyDb.dbo.SomeTable s
JOIN OtherDb.dbo.LargeTable l
ON (expression);

Tracking changes in table

I m working with pgsql .I want to save the audit record to any file system(spread sheet,word...). ie, I have a web application. Any changes(insert,delete,update) occur in the app, will recorded in the audit logg table.But no of tables are in db also each table have more than 5000 rows. so it is difficult (bulk data)to save audit logg as a table.So I want to save audit log as a file in pgSQL. How can it implement?
Thankyou..
Veena.I have worked on pgsql past 2 years back.To my knowledge,To configure a PostgreSQL database as a standalone audit log database or to save audit file, just follow this.firstly Gather database information after that create the audit store schema and configure a PostgreSQL Server data source for CA SiteMinder and Point the Policy Server to the database finally restart the policy server.
You can create the logging schema so the pgsql server database can store audit logs.
To create audit logs,Open sm_postgresql_logs.sql in a text editor and copy the contents of the entire file and start a SQL client, such as psql, and log in as the user who administers the Policy Server database.Select the database instance from the database list and paste the schema from sm_postgresql_logs.sql into the query after that execute the query.
The audit log store schema is created in the database.
Hope this will help you.