How to Create a Table Only if it Doesn’t Exist in PostgreSQL

In PostgreSQL, you can use the IF NOT EXISTS clause of the CREATE TABLE statement to check whether or not a table of the same name already exists in the database before creating it.

The table will only be created if no other table exists with the same name. If a table already exists with that name, a “notice” will be issued instead of an error.

Continue reading

Create a Collection in MongoDB

When you create a database in MongoDB, your database is basically an empty container for which you can add one or more collections to.

A collection is analogous to a table in relational databases.

In relational databases, you can use CREATE TABLE to create each table that you want in the database.

But MongoDB is not a relational database, and it stores its data as documents. Each document is stored in a collection.

This article shows you how to create a collection in MongoDB.

Continue reading

2 Ways to Create a Table on a Linked Server using T-SQL

If you need to create a table on a linked server, you can do this either directly on the remote server, or you can do it by running a script from your local server.

Here are two ways of using T-SQL to create a table on a linked server.

Both methods use the EXECUTE/EXEC statement. But each uses a different approach.

Continue reading