There are various methods for cloning/copying tables with SQL, but not all methods are supported by all RDBMSs.
Below are two options for cloning a table in SQL Server.
Continue readingThere are various methods for cloning/copying tables with SQL, but not all methods are supported by all RDBMSs.
Below are two options for cloning a table in SQL Server.
Continue readingIn SQL Server, we can use sequences to generate sequence numbers that increment by a specified amount. This means that any new number generated by the sequence will be the next sequential increment as specified in the sequence’s definition.
Normally, this is exactly what we want. We want each number to adhere to the increment that we specified when defining the sequence.
But what if we want to reset the sequence, so that the numbering starts all over again? In other words, we want to restart the sequence from the beginning. Or what if we want to reset the sequence so that it increments in a different range?
Fortunately, we can reset a sequence with the ALTER SEQUENCE
statement.
MySQL provides us with several ways to copy a database table. The method we use will depend on our requirements.
We can choose to copy the table, its data, and its indexes. Or we can copy just the table and data without the indexes. We can alternatively generate the code that will enable us to copy the table later.
Continue readingIf you’re not sure if a table has a generated column in SQLite, you can quickly find out with either the .schema
command, or by querying the sqlite_schema
table.
We can use the SQL INSERT
statement to insert a row into a table. We can also use it to insert more than one row.
Below are seven ways to insert multiple rows into a table in SQL. Most of these examples should work in the major RDBMSs, with the possible exception of Oracle. But no worries, I’ve included an example just for Oracle.
Continue readingIn SQLite, we can use the TIME()
function to add a given number of minutes to a time value.
If we’re dealing with datetime values, we can use the DATETIME()
function.
If you have a table in MariaDB with a generated column, you can use the following methods to find out its definition.
Continue readingIn SQLite, we can use the TIME()
function to add a given number of hours to a time value.
If we’re dealing with datetime values, we can use the DATETIME()
function.
Here are five ways to see whether a table contains a generated column in MariaDB.
Continue readingIn MariaDB, we can use the LOWER()
function to convert uppercase characters to their lowercase equivalent.
We can alternatively use LCASE()
, which is a synonym of LOWER()
.