WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder



Go Back Add a Comment Send this Article to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES SUBMIT AN ARTICLE PRINT
Title : Descriptions of Common Data Types
Categories : MySQL, Databases, PHP, PHP options/info, General Picture not available
Meloni Julie
Date : 2000-04-29
Grade : 1 of 5 (graded 1 times)
Viewed : 12037
Search : More Articles by Meloni Julie
Action : Grade This Article
Tools : My Favotite Articles


Submit your own code examples 
 


In Chapter 4, "Creating and Populating Database Tables" of PHP Essentials, I showed you a series of scripts used to create a database table. What I didn't do very well was explain the data types that are commonly used in MySQL (and other databases), as the limitations on field lengths and what not. For example, if you try to create a field of type TEXT and you give it a length, you'll probably get an error in your SQL statement.



The following chart is a handy reference to common data types. It's a short version of what can be found in the MySQL manual at http://www.mysql.com/Manual_chapter/manual_Reference.html#Column_types. For other database types, many of these definitions will hold true. However, always check your own database documentation to be sure!



DATA TYPE DESCRIPTION DEFINE LENGTH?
TINYINT A very small integer. SIGNED range is -128 to 127. UNSIGNED range is 0 to 255. Not required; defaults to 4.
SMALLINT A small integer. SIGNED range is -32768 to 32767. UNSIGNED range is 0 to 65535. Not required; defaults to 5.
MEDIUMINT A medium-sized integer. SIGNED range is -8388608 to 8388607. UNSIGNED range is 0 to 16777215. Not required; defaults to 9.
INT or INTEGER A normal-sized integer. SIGNED range is -2147483648 to 2147483647. UNSIGNED range is 0 to 4294967295. Not required; defaults to 11.
BIGINT A large integer. SIGNED range is -9223372036854775808 to 9223372036854775807. UNSIGNED range is 0 to 18446744073709551615. Not required; defaults to 21.
FLOAT A floating-point number that cannot be unsigned. Not required; defaults to 10,2 where "2" is the number of decimals. Decimal precision can go to 24 for a FLOAT.
REAL or DOUBLE A double-precision floating-point number that cannot be unsigned. Not required; defaults to 16,4 where "4" is the number of decimals. Decimal precision can go to 53 for a DOUBLE.
NUMERIC or DECIMAL An unpacked floating-point number that cannot be unsigned. Yes; both the display width (amount of numbers before the decimal point) and the decimal precision must be indicated (i.e. "17,15").
DATE A date, in YYYY-MM-DD format, between 1000-01-01 and 9999-12-31. No.
DATETIME A date and time combination, in YYYY-MM-DD HH:MM:SS format, between 1000-01-01 00:00:00 and 9999-12-31 23:59:59. No.
TIMESTAMP A timestamp, between 1970-01-01 00:00:00 and sometime in 2037. TIMESTAMP depends on the assigned length of the field. If length is 14, TIMESTAMP is YYYYMMDDHHMMSS. If length is 12, TIMESTAMP is YYMMDDHHMMSS. If length is 8, TIMESTAMP is YYYYMMDD. If length is 6, TIMESTAMP is YYMMDD. Not required; defaults to 14. Can be 6, 8, 12 or 14.
TIME Time, in HH:MM:SS format. No.
YEAR A year, in 2 digit or 4 digit format. If length is 2, YEAR can be 1970 to 2069 (70 to 69). If length is 4, YEAR can be 1901 to 2155. Not required; defaults to 4.
CHAR A fixed-length string between 1 and 255 characters in length, right-padded with spaces to the specified length when stored. Not required; defaults to 1.
VARCHAR A variable-length string between 1 and 255 characters in length. Yes.
TINYBLOB or TINYTEXT A BLOB or TEXT column with a maximum length of 255 characters. No.
MEDIUMBLOB or MEDIUMTEXT A BLOB or TEXT column with a maximum length of 16777215 characters. No.
LONGBLOB or LONGTEXT A BLOB or TEXT column with a maximum length of 4294967295 characters. No.
BLOB or TEXT A BLOB or TEXT column with a maximum length of 65535 characters. No.







Beginners guide to PHP and MySQL
Categories : PHP, Beginner Guides, Databases, MySQL, Installation
Creating an IE-Only Database Driven Menu System With PHP, MySQL and DHTML
Categories : PHP, MySQL, Databases, DHTML
Building A Persistent Shopping Cart With PHP and MySQL
Categories : PHP, MySQL, Databases, Ecommerce
Case Study: Handling MySQL Growth With a PHP Class
Categories : Databases, MySQL, PHP
PHP, MySQL and Authentication 101
Categories : PHP, Databases, MySQL, Authentication
Practical Date and Time examples with PHP and MySQL
Categories : Databases, MySQL, PHP, Date/time
Alternating row colors with PHP and mySQL
Categories : PHP, Databases, MySQL, HTML and PHP
Miles To Go Before I Sleep...
Categories : PHP, Calendar, Databases, MySQL
Multicolumn Output from a Database with PHP
Categories : PHP, Databases, HTML and PHP, MySQL
Simple Connection to MySQL with PHP
Categories : PHP, MySQL, Databases
Time Is Money Part 1 of 2 - Designing and implementing a Web-based application
Categories : PHP, Databases, MySQL, Complete Programs
Date Arithmetic With MySQL
Categories : PHP, Databases, MySQL, Date Time
User identification using cookies in PHP and MySQL
Categories : PHP, Databases, MySQL, Cookies
Creating Auto-incrementing ID Fields with PHP and Oracle
Categories : PHP, PHP options/info, Databases, Oracle
PHP and MySQL News with Comments
Categories : PHP, Databases, MySQL
Anonymous wrote : 240
hi,
i am looking for c++ api on linux for mysql.can anyone
help me .
Also is there an restriction on max number of columns
an mysql can have.plz help in this regard