ol….)
删除索引:drop index idxname
注:索引是不可更改的,想更改必须删除重新建。
32.说明:
创建视图:create view viewname as select statement
删除视图:drop view
viewname
33.说明:几个简单的基本的sql语句
选择:select * from table1 where范围
插入:insert into
table1(field1,field2) values(value1,value2)
删除:delete from table1 where
范围
更新:update table1 set field1=value1 where范围
查找:select * from table1
where field1 like’%value1%’ ---like的语法很精妙,查资料!
排序:select * from table1
order by field1,field2 [desc]
总数:select count * as totalcount from
table1
求和:select sum(field1) as sumvalue from table1
平均:select
avg(field1) as avgvalue from table1
最大:select max(field1) as maxvalue from
table1
最小:select min(field1) as minvalue from table1
31、简单查询
select name from bbc where population>=200000000; --查询显示出人口不小于2亿的国家名字
select name ,(gdp/population)'人均GDP' from bbc where population>=200000000; --人口不小于200000000国家名称及人均gdp
select name , round((populatio/1000000))'人口数(百万)' from bbc where name in(south asia);
select name,popultion from bbc where name ='France', 'Germany', 'Italy'; --查询出france,germany,italy三国的人口数
select name from bbc where name like '%united%'查询出国家名称包括united字符的的所有国家名称;
表获得诺贝尔奖
select yr,subject winner from nobel where yr = 1950; --显示1950年获得诺贝尔奖的人.的所有信息
select winner from nobel where yr =1962; --1962文学奖获得者
select yr,subject from nodel where winner ='albert einstin'; --显示'Albert Einstein'获奖的年份和奖项.
select winner from nodel where yr>=2000 and subject = '和平奖';--2000年以来(包含2000年)和平奖的得主.
select * from nodel where yr between 1980 and 1989 and subject = '文学奖'; --1980到 1989间文学奖获得者的所有信息
select *from nodel where winner=('Theodore Roosevelt', 'Woodrow Wilson', 'Jed Bartlet', 'Jimmy Carter');
select winner from nodel where winner like 'john%'