TYPE OF VALUES IN SQL
SQL supports various data types to represent different kinds of values. Here are some common SQL data types:
**1. Numeric Types:**
- **INT** or **INTEGER**: Integer values (e.g., 1, 10, -5).
- **NUMERIC** or **DECIMAL**: Fixed-point or floating-point numbers.
- **FLOAT**: Floating-point numbers with decimal places.
- **REAL**: Single-precision floating-point numbers.
- **DOUBLE** or **DOUBLE PRECISION**: Double-precision floating-point numbers.
**2. Character Strings:**
- **CHAR(n)**: Fixed-length character string (e.g., CHAR(10)).
- **VARCHAR(n)**: Variable-length character string (e.g., VARCHAR(255)).
- **TEXT**: Variable-length text.
**3. Date and Time Types:**
- **DATE**: Date values (e.g., '2023-10-14').
- **TIME**: Time values (e.g., '12:30:00').
- **TIMESTAMP**: Date and time combined (e.g., '2023-10-14 12:30:00').
**4. Boolean Type:**
- **BOOLEAN**: Represents true or false values.
**5. Binary Data Types:**
- **BINARY(n)**: Fixed-length binary data.
- **VARBINARY(n)**: Variable-length binary data.
- **BLOB**: Binary Large Object for storing large binary data.
**6. Enumerated Types:**
- **ENUM**: Represents a static, ordered set of values.
**7. Geometric Types:**
- **POINT**: Represents a 2D point.
- **LINE**: Represents a line.
- **POLYGON**: Represents a polygon.
**8. Network Address Types:**
- **CIDR**: Represents an IPv4 or IPv6 network address.
- **INET**: Represents an IPv4 or IPv6 host address.
- **MACADDR**: Represents a MAC address.
**9. UUID Type:**
- **UUID**: Universally Unique Identifier.
**10. Arrays:**
- **ARRAY**: Represents an array of values.
**11. JSON Types:**
- **JSON**: Stores JSON-formatted data.
**12. XML Type:**
- **XML**: Stores XML data.
**13. Money Type:**
- **MONEY**: Represents currency values.
**14. Bit Strings:**
- **BIT(n)**: Fixed-length bit string.
- **BIT VARYING(n)**: Variable-length bit string.
**15. Interval Types:**
- **INTERVAL**: Represents a time interval.
**16. Custom User-Defined Types:**
- You can create your own data types in some database systems.
Each database system may have slight variations in supported data types and their names, but these are the most common types you'll encounter in SQL. The choice of data type depends on the nature of the data you're storing and the specific requirements of your database.
Comments
Post a Comment