SQL ALTER DATABASE Syntax – Listed by DBMS

This article contains the SQL ALTER DATABASE syntax, as implemented by various database management systems (DBMSs). The syntax is listed exactly as each vendor has listed it on their website. Click on the applicable link to view more detail about the syntax for a particular vendor.

The DBMSs covered are MySQL, SQL Server, PostgreSQL, and Oracle Database.

Continue reading

SQL CREATE TABLE Syntax – Listed by DBMS

This article contains the SQL CREATE TABLE syntax, as implemented by various database management systems (DBMSs). The syntax is listed exactly as each vendor has listed it on their website. Click on the applicable link to view more detail about the syntax for a particular vendor.

The DBMSs covered are MySQL, SQL Server, PostgreSQL, and Oracle Database.

Continue reading

SQL CREATE DATABASE Syntax – Listed by DBMS

This article contains the SQL CREATE DATABASE syntax, as implemented by various database management systems (DBMSs). The syntax is listed exactly as each vendor has listed it on their website. Click on the applicable link to view more detail about the syntax for a particular vendor.

The DBMSs covered are MySQL, SQL Server, PostgreSQL, and Oracle Database.

Continue reading

What is a Database Schema?

In database terms, a schema (pronounced “skee-muh” or “skee-mah”) is the organisation and structure of a database. Both schemas and schemata can be used as plural forms.

A schema contains schema objects, which could be tablescolumns, data types, views, stored procedures, relationships, primary keys, foreign keys, etc.

A database schema can be represented in a visual diagram, which shows the database objects and their relationship with each other.

Screenshot of a database schema.
A basic schema diagram representing a small three-table database.

Above is a simple example of a schema diagram. It shows three tables, along with their data types, relationships between the tables, as well as their primary keys and foreign keys.

Continue reading

Is it Pronounced “S-Q-L” or “Sequel”?

Ever since its early days, there’s confusion over how to pronounce SQL. If you’ve ever worked in a large team of SQL developers, you might’ve heard some developers pronouncing it as “S-Q-L” or “ess-que-ell” [ ˈɛs kjuː ˈɛl ] and others using “sequel” [ ˈsiːkwəl ].

And the confusion extends itself to commercial and open source products too. Any mispronunciation will extend itself to products such as SQL Server and MySQL, not to mention product tools and features such as MySQL Workbench, mysqladmin, mysqldump, and Access’s SQL view, to name a few.

Continue reading

What is MySQL?

MySQL is an open source relational database management system (RDBMS). It is the world’s most popular open source RDBMS and is currently ranked as the second most popular RDBMS in the world (behind Oracle Database).

MySQL is available as a free download, however, several paid editions are also available which offer additional functionality.

As the name suggests, MySQL is based on SQL. The “My” part is named after co-founder Michael Widenius’ daughter, My.

Continue reading

How to Create a Relationship in MySQL Workbench

To create a relationship in MySQL Workbench:

  1. Create a database model (either create a new model or reverse engineer an existing database)
  2. Viewing the database model, double click on the first table of the relationship
  3. The bottom pane will open with the table details. Click on the Foreign Keys tab
  4. In the left pane, select the foreign key field and referenced table
  5. In the middle pane, select the foreign column and referenced (primary key) column
  6. In the right pane, set any Update/Delete actions you’d like to occur when a primary key record is updated or deleted

The relationship is now established. Repeat steps 4 to 6 for any other foreign key columns in that table.

Continue reading

How to Reverse Engineer a Database in MySQL Workbench

To reverse engineer a database in MySQL Workbench:

  1. Select Database > Reverse Engineer from the top menu of MySQL Workbench
  2. Set/review parameters for connecting to the DBMS then click Continue
  3. Enter password if required, then click OK
  4. The wizard will connect to the DBMS, fetch a list of databases, and check for any issues. Click Continue
  5. Select the database/s you would like to reverse engineer, then click Continue
  6. The wizard will retrieve all objects from the selected schema/s and check the results. Click Continue
  7. Select the database objects you’d like to have reverse engineered, then click Execute
  8. The wizard will now reverse engineer all selected objects and generate the EER diagram (behind the scenes). Click Continue
  9. A summary is displayed. Click Close

The EER diagram is now displayed on the screen.

Continue reading