Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Databases Programming Interviews:BtrieveClipperData ModelingData StructuresDatabase AdministrationDatabase Administrator (DBA)Database AnalystDatabase DeveloperDB DevelopmentEDI/Data Integration ExpertFirebirdHierarchicalIBM DB2InformixJava DatabaseMariaDBMicrosoft Access DeveloperMongoDBMS SQL ServerMySQL ProgrammingNetworkNoSQLObject RelationalPostgrePostgreSQLProgressRDBMSRelationalSQLSQL AdministratorSQL and PL/SQLSQL Notification ServicesSQL server 2008SSRSStored ProcedureSybaseTeradata
Copyright © 2018. All Rights Reserved
MS SQL Server Interview Question:
How To Create an Index on an Existing Table in MS SQL Server?
Submitted by: AdministratorIf you want to an index on an existing table, you can use the CREATE INDEX statement in a simple syntax:
CREATE INDEX index_name ON table_name (column_name)
The tutorial exercise below shows you how to add an index for the "in" column of the "ggl_links" table:
USE GlobalGuideLineDatabase;
GO
-- Drop the old table, if needed
DROP TABLE ggl_links;
GO
-- Create a fresh new table
CREATE TABLE ggl_links (
id INT NOT NULL,
url VARCHAR(80) NOT NULL,
notes VARCHAR(1024),
counts INT,
created DATETIME NOT NULL DEFAULT(getdate())
);
GO
-- Create an index for "id"
CREATE INDEX ggl_links_id ON ggl_links (id);
GO
-- Create an index for "url"
CREATE INDEX ggl_links_url ON ggl_links (url);
GO
Submitted by: Administrator
CREATE INDEX index_name ON table_name (column_name)
The tutorial exercise below shows you how to add an index for the "in" column of the "ggl_links" table:
USE GlobalGuideLineDatabase;
GO
-- Drop the old table, if needed
DROP TABLE ggl_links;
GO
-- Create a fresh new table
CREATE TABLE ggl_links (
id INT NOT NULL,
url VARCHAR(80) NOT NULL,
notes VARCHAR(1024),
counts INT,
created DATETIME NOT NULL DEFAULT(getdate())
);
GO
-- Create an index for "id"
CREATE INDEX ggl_links_id ON ggl_links (id);
GO
-- Create an index for "url"
CREATE INDEX ggl_links_url ON ggl_links (url);
GO
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.