MySQL - CREATE
How to use the MySQL CREATE command to create databases and tables.
CREATE DATABASE
Syntax
It is much easier to create a database from the admin section of your hosting account but you can also write a query to do it. This is the MySQL query used to create a database in MySQL. Some web hosts don't allow privileges to create a database from the phpMyAdmin client. If this code doesn't work then you'll have to create the database from the admin section of your host acount.Syntax CREATE DATABASE databasename
Example SQL Code:
|
CREATE DATABASE vbulletin |
||
CREATE TABLE
Syntax
Creating a table is easier to do with phpMyAdmin but you can also write a query if you want. The order in which the commands are written will be the order of the columns in the database. I'm leaving out the password field there because we will deal with it later.Syntax CREATE TABLE tablename (
column1name description,
column2name description
);
Example SQL Code:
|
CREATE TABLE user ( userid INT(12) UNSIGNED UNIQUE AUTO_INCREMENT, firstname VARCHAR(20), lastname VARCHAR(20), email VARCHAR(50) NOT NULL, creationdate DATETIME, PRIMARY KEY(id) ); |
||
Bookmark this page: |
Rate this page: |
Comments:
| please post comments | ||
|
admin November 21, 2006 |
||











