In SQLite, the ceil()
and ceiling()
functions are used to return the smallest integer that is greater than or equal to a given number. They both serve the same purpose, and either function can be used interchangeably.
Author: Ian
Fixing Error 1066 When Using the HANDLER Statement in MySQL
If you’re getting MySQL error 1066 which reads something like “1066 (42000): Not unique table/alias: ‘products’” when using the HANDLER
statement in MySQL, it could be that you’re trying to open a table that’s already open.
If this is the case, be sure to close the table before trying to open it again. Or simply continue working without opening the table again.
Continue readingUnderstanding the RADIANS() Function in SQLite
The RADIANS()
function in SQLite is a mathematical function that converts an angle from degrees to radians. This can be handy when working with trigonometric calculations in your database queries, as some mathematical functions (such as SIN()
, TAN()
) expect angles in radians rather than degrees.
The 6 SERIAL Data Types in PostgreSQL
The SERIAL
data type in PostgreSQL is a pseudo-type used to create an auto-incrementing sequence of integers for a column. It is commonly used for primary keys, as it eliminates the need to manually assign unique identifiers for each new record. PostgreSQL handles this by automatically creating a sequence object that supplies a unique number each time a new row is inserted.
PostgreSQL provides three SERIAL
types, each with two options for usage; which effectively equates to six different types. So basically, we have six options to choose from when creating a SERIAL
column.
How ASIN() Works in SQLite
The ASIN()
function in SQLite calculates the arc sine (inverse sine) of a given numeric value. The result is the angle in radians whose sine is the specified number.
Understanding the ACOS() Function in SQLite
The ACOS()
function in SQLite is used to calculate the arc cosine (inverse cosine) of a given numeric value. The result is the angle in radians whose cosine is the specified number.
List All Prepared Statements in MySQL
MySQL provides us with the ability to create server-side prepared statements, which are precompiled SQL queries that can be executed multiple times with different arguments.
We can use the performance schema to return a list of all prepared statements in the server, along with useful information about each prepared statement.
Continue readingFix “Column … in field list is ambiguous” in MySQL (Error 1052)
If you’re getting an error that reads something like “1052 (23000): Column ‘name’ in field list is ambiguous” in MySQL, it looks like you could be referencing a column name in a query without qualifying it with the table name.
This can happen when you perform a join between tables that use the same name for one or more columns.
To fix this issue, be sure to qualify column names with the table names when performing joins across tables.
Continue readingHow to Capture All Rows Deleted by a DELETE Statement in SQL Server
Any time you prepare to delete data from a database, you will probably wonder whether or not to log the deleted data somewhere… just in case.
One way to do this is to construct a SELECT
statement to identify the rows you want to delete, and then use it to copy those rows into a separate log table, before doing the actual delete. If you’re using SQL Server, another option is to use the OUTPUT
clause. This article discusses the later.
Why it’s a Good Idea to Create Indexes on Foreign Keys in PostgreSQL
When a foreign key is defined in a table, it ensures that the values in the column(s) correspond to values in a primary key or unique key in another table. While PostgreSQL automatically creates an index for primary keys (because these need to be fast for lookups and enforcing uniqueness), it does not automatically create an index for foreign keys.
Continue reading