Create DB & Table Queries

From TRCCompSci - AQA Computer Science
Revision as of 13:02, 24 December 2016 by Admin (talk | contribs)
Jump to: navigation, search

Creating A Database

Once you have an sql server / phpmyadmin running, you will need to create a database. This is very simple:

Create Database DBName ;

so to create a database called my_db:

Create Database my_db ;

Creating A Table

Now you have a database, you will need to create a table within your database. The create table sql should give a name for the table and then the name of each field and its data type & size.

Create Table table_name
(
column_name1 data_type(size),
column_name2 data_type(size),
column_name3 data_type(size),
....
);