...

View Full Version : Create Table With Default Values



Cerby
11-15-2007, 06:42 PM
Hello! I have the following code that creates a table structure. How do I give Age a default value of 0



mysql_select_db("DB", $connection);
$sql = "CREATE TABLE Person
(
Name text,
Age text,
Sex text
)";

aedrin
11-15-2007, 06:45 PM
Look up the MySQL reference manual.

barkermn01
11-15-2007, 11:40 PM
Hello! I have the following code that creates a table structure. How do I give Age a default value of 0



mysql_select_db("DB", $connection);
$sql = "CREATE TABLE Person
(
Name text,
Age text,
Sex text
)";


Sorry that is Soooo Wrong
one thing Mysql dose not knwo what text is

Varchar - Has to be followed by the ammount of diggets used

And there is nothing there telling mysql there is a deafult no. as far as it is conserned they all are allowed Vale of NULL

If you google PHP MYSQL Create Table - you will get some good tutorial
and for Defaults Serch MYSQL DEFAULT btw hate to say this but check this site out
http://www.just****inggoogleit.com

Inigoesdr
11-16-2007, 12:32 AM
Mysql dose not knwo what text is

Yes, MySQL does (http://dev.mysql.com/doc/refman/5.1/en/string-type-overview.html).

barkermn01
11-16-2007, 11:43 AM
Yes, MySQL does (http://dev.mysql.com/doc/refman/5.1/en/string-type-overview.html).

Sorry Vesion 5.1 Dose
4.5 - Most Web servers still running Dosent there is varchar or Memo
And from what i read about text from read about Text is stors Data Verry big i say stick with memo for texts over and not to mension

Users VARCHAR(255)
Or
Users MEMO
Or
c2 TEXT CHARACTER SET latin1 COLLATE latin1_general_cs - hrm with 2 are easyer to write
That form your own link mate read befor you post

aedrin
11-16-2007, 04:15 PM
4.5 - Most Web servers still running Dosent there is varchar or Memo

All my hosts run at least 5.1. And I remember using the Text type since at least 4, but I might be wrong.


And there is nothing there telling mysql there is a deafult no. as far as it is conserned they all are allowed Vale of NULL

Hence the person asking the question.

And whether it is allowed NULL or not has nothing to do with the question.

Inigoesdr
11-16-2007, 06:46 PM
And I remember using the Text type since at least 4, but I might be wrong.

No, you're right. It's in MySQL 4 (http://dev.mysql.com/doc/refman/4.1/en/string-type-overview.html) too.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum