创建表,插入列....

--创建表
create table worth(
                   evday varchar2(52),
                   weather varchar2(10),
                   temperature number(10))
select * from worth;
--插入行内容
insert into worth (evday,weather, temperature)
values (to_char(sysdate,'yyyy/mm/dd'),'阴天',30);
insert into worth (evday,weather,temperature)
values (to_char(sysdate+1,'yyyy/mm/dd') ,'雨天',20);
insert into worth (evday,weather,temperature)
values  (to_char(sysdate+2,'yyyy/mm/dd') ,'雨天',22);
insert into worth (evday,weather,temperature)
values  (to_char(sysdate+3,'yyyy/mm/dd') ,'阴转小雨天',25);
insert into worth (evday,weather,temperature)
values  (to_char(sysdate+4,'yyyy/mm/dd') ,'大雨',22);
insert into worth (evday,weather,temperature)
values  (to_char(sysdate+5,'yyyy/mm/dd') ,'大雨转阴天',22);
--增加列
alter  table worth 
add (出行方式 varchar(20),晨练指数 number(10));
alter table worth 
add (心情 char(20),旅游 char );
--删除列 一定要column 
alter table  worth drop
COLUMN 旅游;
alter table  worth drop
COLUMN 心情;
alter table worth 
drop column 出行方式;

--drop table worth;
select to_char(sysdate,'yyyy-mm-dd') from dual;
delete worth;
--重命名表名
rename worth to werther_day;
select * from werther_day;
rename werther_day to weath;
rename weath to worth;
insert into worth (晨练指数 , 心情)
values ( 5 ,'good')
where temperature= 22
update  worth
set 晨练指数 = 3,心情='good'
where evday = '2017/07/17';
update  worth
set 晨练指数 = 5,心情='wonderful'
where evday = '2017/07/18';
update  worth
set 晨练指数 = 6,心情='beautiful'
where evday = '2017/07/19';
update worth
set  晨练指数 = 6,心情='beauty and wonder'
where evday = '2017/07/20';
delete worth
where evday = '2017/07/21';

 

posted @ 2017-07-18 18:38  fy02223y  阅读(155)  评论(0编辑  收藏  举报