What is a “distributed transaction”?

Usually, transactions occur on one database server: BEGIN TRANSACTION SELECT something FROM myTable UPDATE something IN myTable COMMIT A distributed transaction involves multiple servers: BEGIN TRANSACTION UPDATE amount = amount – 100 IN bankAccounts WHERE accountNr = 1 UPDATE amount = amount + 100 IN someRemoteDatabaseAtSomeOtherBank.bankAccounts WHERE accountNr = 2 COMMIT The difficulty comes from … Read more

Command-line/API for Schema Compare in SSDT SQL Server Database Project?

SOURCE Database sqlpackage.exe /a:Extract /scs:Server=%Server%;Database=AspBaselineDB; /tf:%DriveSpec%\%DacPath%\%AspBaselineDB%_baseline.dacpac TARGET Database sqlpackage.exe /a:Extract /scs:Server=%Server%;Database=%AspTargetDB-2%; /tf:%DriveSpec%\%DacPath%\%AspTargetDB%.dacpac COMPARE & GENERATE the Delta script sqlpackage.exe /a:Script /sf:%DriveSpec%\%DacPath%\%AspBaselineDB%_baseline.dacpac /tf:%DriveSpec%\%DacPath%\AspNetDb\%AspTargetDB%.dacpac /tdn:aspTargetdb /op:%DriveSpec%\%SqlPath%\AspNetDb\AspDbUpdate.sql EXECUTE the script sqlcmd.exe -S %Server%\aspnetdbAmexDev -i %DriveSpec%\%SqlPath%\AspNetDb\AspDbUpdate.sql I do this in CMD scripting as our IT dept will not allow unsigned PowerShell scripts and they won’t purchase a cert. This … Read more

How to work with liquibase, a concrete example

You should never modify a <changeSet> that was already executed. Liquibase calculates checksums for all executed changeSets and stores them in the log. It will then recalculate that checksum, compare it to the stored ones and fail the next time you run it if the checksums differ. What you need to do instead is to … Read more

Error ORA-00932 when using a select with union and CLOB fields

I believe the problem is the use of UNION instead of UNION ALL. The UNION operator will combine the two sets and eliminate duplicates. Since CLOB types cannot be compared, the duplicate elimination part is not possible. Using UNION ALL won’t attempt to do duplicate elimination (you probably don’t have duplicates anyways) so it should … Read more

Databases versus plain text

1) Concurrency. Do you have multiple people accessing the same dataset? Then it’s going to get pretty involved to broker all of the different readers and writers in a scalable fashion if you roll your own system. 2) Formatting and relationships: Is your data something that doesn’t fit neatly into a table structure? Long nucleotide … Read more

Why use a 1-to-1 relationship in database design?

From the logical standpoint, a 1:1 relationship should always be merged into a single table. On the other hand, there may be physical considerations for such “vertical partitioning” or “row splitting”, especially if you know you’ll access some columns more frequently or in different pattern than the others, for example: You might want to cluster … Read more

How Can I Automatically Populate SQLAlchemy Database Fields? (Flask-SQLAlchemy)

Just add server_default or default argument to the column fields: created_on = db.Column(db.DateTime, server_default=db.func.now()) updated_on = db.Column(db.DateTime, server_default=db.func.now(), server_onupdate=db.func.now()) I prefer the {created,updated}_on column names. 😉 SQLAlchemy docs about column insert/update defaults. [Edit]: Updated code to use server_default arguments in the code. [Edit 2]: Replaced onupdate with server_onupdate arguments.

Trying to get Postgres setup in my environment but can’t seem to get permissions to intidb

This should work just fine: # sudo mkdir /usr/local/var/postgres # sudo chmod 775 /usr/local/var/postgres # sudo chown construct /usr/local/var/postgres # initdb /usr/local/var/postgres use your username in place of construct. So, if your computer username is WDurant, the code will be: # sudo chown $(whoami) /usr/local/var/postgres

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)