Web Hosting Talk







View Full Version : create table question


michael-lane
07-05-2005, 03:51 AM
i'm writing a script but i cant check it cause my host is upgrading cpanel 10.0.4 to cpanel 10.0.5 or sumfing and i want to know can i use:
CREATE TABLE('collumname1', 'collumnname2', 'collumnname3');
do i have to use notnull and int and and stuff really? what properties MUST! i state

error404
07-05-2005, 04:21 AM
You need a column name and a data type. So the int is required as it tells the database what type of data that field will store, as is the column name. The not null is a condition that the database is supposed to enforce (MySQL doesn't properly, so it's pretty pointless).

michael-lane
07-05-2005, 07:00 AM
so i must tell it what type and how long they are allowed to type data upto. Is that int and what?

error404
07-05-2005, 08:05 AM
CREATE TABLE (foo1 INT, foo2 INT); is perfectly valid, and will create a table with two integer columns. The size is not required except for VARCHAR and CHAR fields, and would appear in parens after the type name, like foo3 VARCHAR(30).