当前位置: 代码迷 >> SQL >> sql 目录 视图 建立 删除
  详细解决方案

sql 目录 视图 建立 删除

热度:437   发布时间:2016-05-05 11:37:51.0
sql 索引 视图 建立 删除
--创建索引create unique index uni on bank (customerName) --创建表bank上的唯一索引,索引名uni与表中的customerName列对应drop index bank.uni --删除表bank的索引名为uni的索引--创建非聚集索引 fillfactor表示填充因子,指定一个0~100的值,表示索引页填满的空间所占百分比create nonclustered index nonclu on bank(currentMoney) with fillfactor=30 drop index bank.nonclu--按照指定的索引查询select * from bank(index=nonclu)where currentMoney=80insert into bank (customerName,currentMoney)select '飞鸟',102union select '假面',150union select '娟娟',104select * from bank select * from stuInfo_1goalter table stuInfo_1add constraint pk_name primary key (stuNo)alter table stuInfo_1drop constraint pk_namealter table bank add constraint pk_name1 primary key(bank_id)alter table bank drop constraint pk_name1alter table bankadd constraint fk_name foreign key(bank_id)references stuInfo_1(stuNo)alter table bankdrop constraint fk_namedrop table bankcreate table bank(bank_id varchar(8) not null,customerName varchar(20) not null,currentMoney money)insert into bank(bank_id,customerName,currentMoney)select 's253002','feiniao',120union select 's2530001','jiamian',210union select 's2530006','都都',112union select 's2530004','飞鸟',210union select 's2530005','假面',150union select 's2530003','娟娟',140select * from bankselect * from stuInfo_1select * from view_bank_stuInfo_1godrop view view_bank_stuInfo_1 --删除视图--创建视图(视图一般是仅作为查询使用)create view view_bank_stuInfo_1as select 姓名=stuName,stuNo,stuSex,stuAge,stuSeat,stuAddress,currentMoney from stuInfo_1 inner join bank on bank_id=stuNo

?

  相关解决方案