mysql creating table help
#1

hi

i want to ask how to create tables for mysql scripts for example i downloaded reports system and what kind of tables do i need to make

Код:
CREATE  TABLE  `reports` (
  `id` INT NOT  NULL  AUTO_INCREMENT ,
  `reporter` VARCHAR( 24  )  NOT  NULL ,
  `reported` VARCHAR( 24  )  NOT  NULL ,
  `reason` VARCHAR( 24  )  NOT  NULL ,
  `description` VARCHAR( 68  )  NOT  NULL ,
  `read` INT( 2  ) ,  
  `time` VARCHAR( 24  )  NOT  NULL ,
  PRIMARY  KEY (  `id`  ) 
  )
do i create like table called reports and inside this table id, reporter, reported and so on... and also how do i know what type of table should i make (you know when you have to chose "int" or "varchar"....heaps more) for help + rep
Reply
#2

The syntax is like:
pawn Код:
CREATE TABLE `tablename` (row name datatype (max length of datatype), ....)
For example, say:
pawn Код:
CREATE TABLE `exampletable`(examplerow INT (4)) /* would create a table 'exampletable' with a row 'examplerow' where you can store integers with the max length as 4 i.e. till 9999 only */
Reply
#3

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
The syntax is like:
pawn Код:
CREATE TABLE `tablename` (row name datatype (max length of datatype), ....)
For example, say:
pawn Код:
CREATE TABLE `exampletable`(examplerow INT (4)) /* would create a table 'exampletable' with a row 'examplerow' where you can store integers with the max length as 4 i.e. till 9999 only */
so as you said "CREATE TABLE `tablename`"

is that the main table ?
Reply
#4

Yep. That will be the main table. Here is what the thing is:

Quote:

1 Database >> Many tables >> Each table can have multiple rows.

For example,
Quote:

Example database>> Exampletable, exampletable2>>Example table has rows: example row 1, row2, etc.

Reply
#5

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
Yep. That will be the main table. Here is what the thing is:


For example,
last question xD

so when i create for example "reports" i need to chose how many rows i need

for this script
CREATE TABLE `reports` (
`id` INT NOT NULL AUTO_INCREMENT ,
`reporter` VARCHAR( 24 ) NOT NULL ,
`reported` VARCHAR( 24 ) NOT NULL ,
`reason` VARCHAR( 24 ) NOT NULL ,
`description` VARCHAR( 68 ) NOT NULL ,
`read` INT( 2 ) ,
`time` VARCHAR( 24 ) NOT NULL ,
PRIMARY KEY ( `id` )
)

do i make 7 rows ?
Reply
#6

I would kindly like to request that you read this:
http://dev.mysql.com/doc/refman/5.1/...ate-table.html

It is advised for a coder/scripter to know what he/she is doing. While I don't want to underestimate you, it is pretty clear that you are just blatantly asking away.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)