Collections:
CREATE CLUSTERED INDEX - Adding Clustered Indexes in SQL Server
How To Create a Clustered Index in SQL Server?
✍: FYIcenter.com
If there is no primary key in a table, you can add one clustered index to that table with CREATE CLUSTERED INDEX statement. The tutorial exercise below shows you how to create a clustered index:
USE FyiCenterData; GO -- Drop the old table, if needed DROP TABLE fyi_links; GO -- Create a table with primary key CREATE TABLE fyi_links ( id INT, url VARCHAR(80) NOT NULL, notes VARCHAR(1024), counts INT, created DATETIME NOT NULL DEFAULT(getdate()) ); GO -- Create a clustered index CREATE CLUSTERED INDEX fyi_links_url ON fyi_links (url); GO -- Create a non-clustered index CREATE INDEX fyi_links_created ON fyi_links (created); GO -- View indexes EXEC SP_HELP fyi_links; GO index_name index_description keys ----------------- -------------------------- ---- fyi_links_created nonclustered located on PRIMARY created fyi_links_url clustered located on PRIMARY url
⇒ Creating an Index for Multiple Columns in SQL Server
⇐ Difference Between Clustered and Non-Clustered Indexes in SQL Server
2016-11-13, 2184🔥, 0💬
Popular Posts:
How To Drop an Index in Oracle? If you don't need an existing index any more, you should delete it w...
How to set the current database in SQL Server? Once you are connected to the SQL Server, you should ...
How To Get Year, Month and Day Out of DATETIME Values in SQL Server Transact-SQL? You can use DATEPA...
Can Binary Strings Be Converted into NUMERIC or FLOAT Data Types in SQL Server Transact-SQL? Can bin...
How To Verify a User name with SQLCMD Tool in SQL Server? The quickest way to verify a user name in ...