How to Rename a Table in SQL

In SQL, most RDBMSs allow you to rename a table using the ALTER TABLE statement, which is the statement used to modify the definition of an existing table.

Some RDBMs also include a RENAME statement for renaming tables.

But if you use SQL Server, you’ll need to use the sp_rename stored procedure.

Read more

SQLite DROP TABLE

In SQLite, you can drop a table with the DROP TABLE statement.

You can optionally add the IF EXISTS clause to suppress any errors that might occur if the table doesn’t exist.

Also, if the table is referenced by a foreign key, there are a few things to be aware of.

Read more

SQL Tutorial for Beginners

In this SQL tutorial for beginners, you will create your own database, insert data into that database, and then run queries against that database.

This SQL tutorial will get you running SQL queries in no time!

Read more

3 Ways to Return the Number of Rows in Each Partition in SQL Server (T-SQL)

If you’ve previously created a partitioned table in SQL Server, and you now want to know how many rows are being stored in each partition, here are three queries you can use.

In particular, you can:

  • Query the sys.dm_db_partition_stats view
  • Query the sys.partitions view
  • Use the $PARTITION function in a query

Below are examples of all three.

Read more