Junior — Middle
Can a table in SQL be created without using a clustered index?
sobes.tech AI
Answer from AI
Yes, in SQL a table can be created without a clustered index. In database management systems such as Microsoft SQL Server, a clustered index determines the physical order of data storage in the table. If a clustered index is not created, the table is called a "heap," and data is stored without any specific order.
For example, in SQL Server, you can create a table without a clustered index as follows:
CREATE TABLE Employees (
EmployeeID int PRIMARY KEY NONCLUSTERED,
Name nvarchar(100),
Position nvarchar(100)
);
Here, the primary key is created with a non-clustered index, and the table itself will be stored as a heap.
The absence of a clustered index can affect the performance of select and update operations, so the choice depends on specific requirements and use scenarios.