A little tutorial for me please? Rep+
#1

Can someone explain me how to make a basic .sql database ?
I would like to explain me more about this:
  • int(11)
  • varchar(255)
  • timestamp
  • int(12)
  • PRIMARY KEY
  • ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=173 ;
  • NOT NULL AUTO_INCREMEN
  • NOT NULL DEFAULT CURRENT_TIMESTAMP
PHP код:
CREATE TABLE IF NOT EXISTS `adminlog` (
  `
entryIDint(11NOT NULL AUTO_INCREMENT,
  `
valuevarchar(255NOT NULL,
  `
entryTimetimestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `
tickcountint(12NOT NULL DEFAULT '0',
  
PRIMARY KEY (`entryID`)
ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=173 
Reply
#2

First four are datatypes. For integers, the number between the brackets is used when the "zerofill" option is used; in that case the number gets padded with zeros in front to meet the specified amount of digits.
For the varchar type (variable length string) it denotes the maximum length of the string.

Every table has, or rather should have, a primary key. The primary key uniquely identifies a row in the table. It is used when updating or deleting a row. The primary key mustn't have any intrinsic value (name, e-mail address, social security number, ...) so a surrogate automatically incrementing integer key is often chosen.

There are a few different storage engines. The most common ones are MyISAM and InnoDB. MyISAM is always enabled while InnoDB may not be. If InnoDB is available, then use InnoDB. MyISAM used to be faster retrieving data but the difference between MyISAM and InnoDB in that context is neglectable nowadays.

NOT NULL specifies that the column does not accept NULL values. NULL is special in that it is equal to nothing, not even to itself. If a column is NULL it means the value is unknown. It is different from 0. Let's say you ask someone how many children they have. If the column is 0 you know they have no children. If the column is NULL you don't know how many children they have (yet).

The DEFAULT keyword is followed by a default value for that column. If no value is specified for the column when a new row is inserted the default value will be used.

Much of this information, however, could've been found out by Googling.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)