Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 15 Nov 2001, 20:11
The Doc The Doc is offline
 
Join Date: Nov 2001
*VERY* new to PHP

Hey.

I just started learnin about PHP, from a mate.
He showed my how to do loads of REALLY neat things, but he DIDN'T tell me how to add tables to an SQL database.

Can anyone help me, or point me in the direction of some good tutorials??
Reply With Quote
  #2  
Old 15 Nov 2001, 21:18
jJazz's Avatar
jJazz jJazz is offline
 
Join Date: Nov 2001
For SQL !

HI !

Yuo can use a SQL query:


CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
[table_options] [select_statement]

create_definition:
col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
[PRIMARY KEY] [reference_definition]
or PRIMARY KEY (index_col_name,...)
or KEY [index_name] (index_col_name,...)
or INDEX [index_name] (index_col_name,...)
or UNIQUE [INDEX] [index_name] (index_col_name,...)
or FULLTEXT [INDEX] [index_name] (index_col_name,...)
or [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,...)
[reference_definition]
or CHECK (expr)

type:
TINYINT[(length)] [UNSIGNED] [ZEROFILL]
or SMALLINT[(length)] [UNSIGNED] [ZEROFILL]
or MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]
or INT[(length)] [UNSIGNED] [ZEROFILL]
or INTEGER[(length)] [UNSIGNED] [ZEROFILL]
or BIGINT[(length)] [UNSIGNED] [ZEROFILL]
or REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
or DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]
or FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]
or DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL]
or NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL]
or CHAR(length) [BINARY]
or VARCHAR(length) [BINARY]
or DATE
or TIME
or TIMESTAMP
or DATETIME
or TINYBLOB
or BLOB
or MEDIUMBLOB
or LONGBLOB
or TINYTEXT
or TEXT
or MEDIUMTEXT
or LONGTEXT
or ENUM(value1,value2,value3,...)
or SET(value1,value2,value3,...)

index_col_name:
col_name [(length)]

reference_definition:
REFERENCES tbl_name [(index_col_name,...)]
[MATCH FULL | MATCH PARTIAL]
[ON DELETE reference_option]
[ON UPDATE reference_option]

reference_option:
RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT

table_options:
TYPE = {BDB | HEAP | ISAM | InnoDB | MERGE | MRG_MYISAM | MYISAM }
or AUTO_INCREMENT = #
or AVG_ROW_LENGTH = #
or CHECKSUM = {0 | 1}
or COMMENT = "string"
or MAX_ROWS = #
or MIN_ROWS = #
or PACK_KEYS = {0 | 1 | DEFAULT}
or PASSWORD = "string"
or DELAY_KEY_WRITE = {0 | 1}
or ROW_FORMAT= { default | dynamic | fixed | compressed }
or RAID_TYPE= {1 | STRIPED | RAID0 } RAID_CHUNKS=# RAID_CHUNKSIZE=#
or UNION = (table_name,[table_name...])
or INSERT_METHOD= {NO | FIRST | LAST }
or DATA DIRECTORY="directory"
or INDEX DIRECTORY="directory"

select_statement:
[IGNORE | REPLACE] SELECT ... (Some legal select statement)





directly with query command.

Ex: if you use MySql you can write this:

<?

#This string to connect database
mysql_pconnect("localhost", "username","password");

#This string to create db
mysql_query("CREATE DATABASE dbexample");

#This string to create TABLE
mysql_query("CREATE TABLE prova (id INT (11) not null , test VARCHAR (255) not null ) ");
?>




PS: For MySql, If you can, install a powerfull php script: "phpMyAdmin".
You can download here:
http://phpmyadmin.sourceforge.net/

See you soon

jJazz

Last edited by jJazz; 15 Nov 2001 at 21:24.
Reply With Quote
  #3  
Old 16 Nov 2001, 07:23
Mark Hensler's Avatar
Mark Hensler Mark Hensler is offline
 
Join Date: Oct 2001
mySQL home

search for 'create':
Create Database
Create Table
Alter Table
Reply With Quote
  #4  
Old 16 Nov 2001, 18:03
The Doc The Doc is offline
 
Join Date: Nov 2001
Cool

Thanks guys, that helps a lot
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 10:46.

Layout Options | Width: Wide Color: