Navicat Blog

Preventing All Records from Being Deleted Within a Stored Procedure Oct 6, 2020 by Robert Gravelle

It's fairly common to allow certain users to perform ad-hoc updates or deletions to tables. Data Manipulation Language (DML) operations such as these always come with risk, and incidents may occur where someone accidentally issues a Delete command without a WHERE clause, thereby deleting all rows in a table! Luckily, there are some simple steps you can take to prevent accidental (or deliberate!) destructive DML operations. We'll examine a couple of these in today's blog.

Obtaining Meta-data about Database Table Columns Sep 22, 2020 by Robert Gravelle

Certain relational databases, including MySQL and SQL Server, have an INFORMATION_SCHEMA system database. It contains database metadata, such as the names of databases, tables, the column data types, and even access privileges. It's also sometimes referred to as the data dictionary or system catalog. Regardless of how you refer to it, the INFORMATION_SCHEMA database is the ideal place to obtain details about table columns. In today's blog, we'll use the INFORMATION_SCHEMA database to find out whether or not a column exists and how many columns a particular table has.

Selecting the Second Highest Value from a Table Sep 17, 2020 by Robert Gravelle

It's been said that second place is the first loser. So, who needs an SQL statement to find out who these under achievers are? Surprisingly, a lot of people. In fact, the official term for this type of query is "nth highest value of a column". That's because techniques for selecting the 2nd highest value may also be applied for any value. In today's blog, we'll learn how to use ORDER BY DESC in conjunction with the LIMIT clause to obtain the 2nd highest value, and others, from a table.

Comparing the Semantics of Null, Zero, and Empty String in Relational Databases Sep 8, 2020 by Robert Gravelle

All-too-often, database developers and administrators use Nulls, Zeroes, and Empty Strings interchangeably within their database tables. That's unfortunate, because Null, Zero, and an Empty String each represent something different in relational databases (RDBMS). As such, using these values incorrectly, or choosing the wrong one, can have enormous ramifications on the operation of your database and applications that rely on it. In today's blog, we'll explore how to best utilize the Null, Zero, and Empty String in database design and general usage.

The Many Flavors of the SQL Count() Function Aug 27, 2020 by Robert Gravelle

If you have worked with relational databases (RDBMS) for any length of time, you have almost certainly utilized the SQL COUNT() function. As such, you are no doubt already aware that the COUNT() function returns the number of rows or columns in a table, as filtered by the criteria specified in the WHERE clause. Its flexible syntax and widespread support makes it one of the most versatile and useful functions in SQL. In today's blog, we'll take a look at its many permutations and learn how to obtain a variety of counts.

Navicat Blogs
Feed Entries
Blog Archives
Share