What Is Table in SQL
A Table in SQL is the fundamental structure used to store data in a relational database. It organizes data into rows and columns, much like a spreadsheet.
Key Points about a Table
Rows (Records): Each row represents a single data entry or record.
Columns (Fields): Each column holds data of a specific type (e.g., integer, varchar, date).
Tables have a name and are part of a database schema.
Tables can have constraints like primary keys, foreign keys, unique keys to enforce data integrity.
Structure of a Table
| Column1 (DataType) | Column2 (DataType) | Column3 (DataType) | ... |
|---|---|---|---|
| Data (Row 1) | Data (Row 1) | Data (Row 1) | ... |
| Data (Row 2) | Data (Row 2) | Data (Row 2) | ... |
Creating a Table Example
CREATE TABLE Employees ( EmployeeID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50), HireDate DATE, Salary DECIMAL(10, 2));Summary
Tables store the actual data in rows and columns.
They define the structure and type of data allowed.
They are essential building blocks of a relational database.
Want help with creating or querying tables?