create a data base code example

Example 1: create database in mysql

The CREATE DATABASE statement is used to create a new SQL/MySQL database.

Syntax
CREATE DATABASE databasename;

CREATE DATABASE Example
The following SQL statement creates a database called "testDB":

Example
CREATE DATABASE testDB;

Example 2: create a db

#TO Create a DB :
CREATE DATABASE <DB_NAME>;
#example : CREATE DATABASE MyDataBase ;
#To Create a Table :
CREATE TABLE <TB_NAME>(
    <Elem 0> <Type_of_Elem created> <ADD_PROPRETIES>, #Don't forget the comma
  	...
  	...
  	...
    <Elem n> <Type_of_Elem created> #last elems don't need a comma 
);
/*example :
CREATE TABLE city (
    id int  NOT NULL IDENTITY(1, 1),
    city_name char(128)  NOT NULL,
    lat decimal(9,6)  NOT NULL,
    long decimal(9,6)  NOT NULL,
    country_id int  NOT NULL,
    CONSTRAINT city_pk PRIMARY KEY  (id)
);
*/

Tags:

Misc Example