An SQL data type tells a database what kind of value an attribute or column stores. Choosing an appropriate type helps the database store data efficiently and supports useful queries. section 4.4 section 4.9
Choose a data type by working from the meaning and expected values of an attribute:
- Examine sample data and the requirements gathered for the subject. section 4.4 section 4.9
- Identify the proper group, such as string, integer, decimal, or temporal. section 4.9
- Select the best fit within that group, considering maximum allowed values or spaces. section 4.9
- Use the selected type when defining the entity’s attributes and implementing the database. section 4.0 section 4.4
Common SQL categories include numeric values such as INT, strings such as TEXT, date or time values such as DATE, Unicode character strings such as VARCHAR, binary values such as BINARY, and miscellaneous values such as XML. In a product table, price can be numeric while manufacturer is a string. section 1.7 section 4.9
Filtering products by typed values
A numeric comparison filters price, while a quoted string filters manufacturer: SELECT * FROM product WHERE price < 30 AND manufacturer = 'Mad Inventors Inc.'; The query combines both criteria with AND and returns matching product rows. section 1.7
SELECT name, description FROM product WHERE price < 30;
This listing provides a compact example of using a numeric data type in a WHERE condition. section 1.7

















