Difference between revisions of "Create DB & Table Queries"
(Created page with "==Creating A Database== once you have an sql server / phpmyadmin running, you will need to create a database. This is very simple: <syntaxhighlight lang=sql> Create Database ...") |
|||
Line 1: | Line 1: | ||
==Creating A Database== | ==Creating A Database== | ||
− | + | Once you have an sql server / phpmyadmin running, you will need to create a database. This is very simple: | |
<syntaxhighlight lang=sql> | <syntaxhighlight lang=sql> | ||
Line 10: | Line 10: | ||
<syntaxhighlight lang=sql> | <syntaxhighlight lang=sql> | ||
Create Database my_db ; | Create Database my_db ; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==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. | ||
+ | |||
+ | <syntaxhighlight lang=sql> | ||
+ | Create Table table_name | ||
+ | ( | ||
+ | column_name1 data_type(size), | ||
+ | column_name2 data_type(size), | ||
+ | column_name3 data_type(size), | ||
+ | .... | ||
+ | ); | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 12:02, 24 December 2016
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),
....
);