Hi,
all member's
How i can create a table in data base ?
Thank's
Hi,
all member's
How i can create a table in data base ?
Thank's
Hi,
It depends on what tools you have avialable to work with. If you are using a graphica interface to a database such as phpMyAdmin then there is a simple inbuilt table creator.
Otherwise you can always create a table using sql.
an example sql startment to create a table is as follows :
CREATE TABLE customer
(First_Name varchar 50 not null,
Last_Name varchar 50 not null,
Address varchar 50 not null,
City varchar 50 not null ,
Country varchar 25 not null,
Birth_Date date);
I hope this helps
Bruce
The SQL syntax for CREATE TABLE is
CREATE TABLE "table_name"
("column 1" "data_type_for_column_1",
"column 2" "data_type_for_column_2",
... )
So, if we are to create the customer table specified as above, we would type in
CREATE TABLE customer
(First_Name char(50),
Last_Name char(50),
Address char(50),
City char(50),
Country char(25),
Birth_Date date)
Sometimes, we want to provide a default value for each column. A default value is used when you do not specify a column's value when inserting data into the table. To specify a default value, add "Default [value]" after the data type declaration. In the above example, if we want to default column "Address" to "Unknown" and City to "Texas", we would type in
CREATE TABLE customer
(First_Name char(50),
Last_Name char(50),
Address char(50) default 'Unknown',
City char(50) default 'Texas',
Country char(25),
Birth_Date date)