SQL Create Database.

Creating a SQL Database

The SQL ANSI standard does not include a CREATE DATABASE command. Instead, it provides a CREATE SCHEMA command for defining the part of a database that a specific user owns.

Creating a database is not always easy in all RDBMS but once you've established the correct permissions the SQL syntax is simple.

Simple Syntax:
CREATE DATABASE  db_name;
Create database example:
MySQL, Oracle, SQL Server, PostgreSQL:
CREATE DATABASE  customerdb;
More specific Syntax for:
MySQL:
CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
[[DEFAULT] CHARACTER SET charset_name
| [DEFAULT] COLLATE collation_name]

character_name is a set of symbols and encodings. DBMS will set a default if not set.
collation_name is a set of rules for comparing characters in a character set. DBMS will set a default if not set.

Create database example:
MySQL:
CREATE DATABASE IF NOT EXISTS customerdb;
To show all existing CHARACTER SET available use:
MySQL:
SHOW CHARACTER SET;
To show all existing COLLATIONS available use:
MySQL:
SHOW COLLATION;
To see the default character set and collation for a given database, use these statements::
MySQL:
USE db_name;
SELECT @@character_set_database, @@collation_database;
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.