Navicat Blog

Copying a Table to a New Table using Pure SQL Apr 28, 2021 by Robert Gravelle

There are many times where one needs to copy data from an existing table to a new one, for example, to back up data or to replicate data in one environment in another, as one might do for testing purposes. In SQL, one would typically use CREATE TABLE and SELECT statements as follows:

CREATE TABLE new_table; 
SELECT SELECT col, col2, col3 
INTO new_table 

In the first statement, the database creates a new table with the name indicated in the CREATE TABLE statement. The structure of the new table is defined by the result set of the SELECT statement. Then, the database populates data with the results of the SELECT statement to the new table.

While the above procedure works perfectly well, there's an easier way to copy a table into a new one using a variation of the CREATE TABLE statement! We'll learn how to use it here today.

Using Transactions in Stored Procedures to Guard against Data Inconsistencies Apr 20, 2021 by Robert Gravelle

In the Understanding Database Transactions blog, we leaned how transactions are a fantastic way to guard against data loss and inconsistencies by guaranteeing that all operations performed with a transaction succeed or fail together. In today's follow-up, we'll learn how to employ a transaction within a stored procedure in order to ensure that all tables involved remain in a consistent state.

Understanding Database Transactions Apr 16, 2021 by Robert Gravelle

Atomicity Consistency Isolation Durability, or "ACID", was coined by Andreas Reuter in 1983. It's a concept in database management systems (DBMS) that identifies a set of standard properties used to guarantee the reliability of a database. ACID properties ensure that all database transactions remain accurate and consistent, and support the recovery from failures that might occur during processing operations. As such, it is implemented by nearly all Relational Databases.

Preventing SQL Injection at the Database Level Apr 14, 2021 by Robert Gravelle

Many organizations make some effort to protect their data by implementing input validation within their applications. As valuable as that is, it should be noted that many cyber attacks are aimed squarely at the database servers themselves, where application security does not come into play at all! As a Database administrator (DBA) or Database Developer, you have tremendous power to reduce the risk of cyber attacks, and/or damage that may occur as a result, including from the most common form of cyber attack: SQL Injection. In today's blog, we'll explore a few practices that can greatly reduce exposure to SQL Injection attacks.

Atomicity in Relational Databases Mar 30, 2021 by Robert Gravelle

Not so long ago, the word "atom" referred to a thing that could not be split any further. Despite having discovered that atoms themselves are made up of even smaller particles, the term continues to retain its original meaning. With respect to relational databases, Atomicity means that operations (DMLs/DDLs, etc.) executed by the database will be atomic. The unit of atomicity usually provided by relational databases is a transaction. Why is this important? A guarantee of atomicity prevents updates to the database occurring only partially, which can cause greater problems than rejecting the whole series of operations outright. In today's blog, we'll learn what Atomicity is and how to enforce it within your database instances.

Navicat Blogs
Feed Entries
Blog Archives