MySql 建表、添加字段、修改字段、添加索引SQL语句写法及SQL索引
---------添加索引方法--------- 1.添加PRIMARY KEY(主键索引) mysql>ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` ) 2.添加UNIQUE(唯一索引) mysql>ALTER TABLE `table_name` ADD UNIQUE ( `column` ) 3.添加INDEX(普通索引) mysql>ALTER TABLE `table_name` ADD INDEX index_name ( `column` ) 4.添加FULLTEXT(全文索引) mysql>ALTER TABLE `table_name` ADD FULLTEXT ( `column` ) 5.添加多列索引 mysql>ALTER TABLE `table_name` ADD INDEX index_name ( `column1`, `column2`, `column3` )
https://www.cnblogs.com/bk7788/p/6050184.html
查看表的索引: show index from table_name(表名) https://blog.csdn.net/superdangbo/article/details/79283752
SQL Server索引
--删除索引 if exists(select name from sysindexes where name = 'suoyin') drop index temp.suoyin ---如果存在这个名字的索引,则删除这个索引 create nonclustered index suoyin_name on temp(Name) --主键,加聚集索引 ALTER TABLE [dbo].[FcyOrder] ADD CONSTRAINT [PK_FcuencyOrder] PRIMARY KEY CLUSTERED ( [FreqOrderId] ASC ) go CREATE NONCLUSTERED INDEX [IX_Code] ON [dbo].[Fct_Product] ([ProductCode]) ON [PRIMARY] GO CREATE INDEX [IX_OrderId] ON [dbo].[FncyOrder] ([OrderId] ASC) GO CREATE INDEX [IDX_Disabled_ChanyCodeAndName] ON [dbo].[Fcommodity] ([Disabled] ASC) INCLUDE ([ChadityCode], [ChaodityName]) GO CREATE UNIQUE INDEX [IDX_SiteWarehouseAndSerialNumber] ON [dbo].[FcquestInfo] ([SerialNumber] ASC, [SiouseId] ASC) WITH (IGNORE_DUP_KEY = ON) GO CREATE UNIQUE INDEX [IX_tockFove_FoveNo] ON [dbo].[TockFove] ([FveNo] ASC) WITH (IGNORE_DUP_KEY = ON) GO
此随笔或为自己所写、或为转载于网络。仅用于个人收集及备忘。