oracle


一、创建表

create table tablename (

id int <not null >| identity(1,1) | primary key | unique ,

name varchar (20) default 'ada')

identity(1,1) 是用来定义逐渐增长的数据 ,(1,1) 第二个参数表示增长幅度,第一个表示参照于前面哪个,如1表示前面一个数的值,2则表示前面第二个数的值


二、alter table 修改表

新增加一个列

alter table tablename

add columnname type(数据类型) 如 alter table plays add pay int default '1000' 往plays中添加工资一列 默认为1000

但是若原先就含有数据,那pay设置为null , 新的数据才显示1000

最好做法就是 alter table plays add pay int default 1000 not null 有了not null 已经存在的数据就会按1000录入


select name,pay,pay*(2+500)
from plays




select name+'name' as 名字加后缀 ,pay
from plays




select distinct pay from plays


select * from plays
where pay between '2000' and '4000'


select * from plays
where pay in( '2000' , ' 5000')


select * from plays
where name like 'l%'




select * from plays
where clubId > 2
and id<7
or name like'l%' //and 的优先级 大于or


select starttime as 时间 from plays
order by 时间 desc //按别名排序


select LOWER(name) 小写 from plays


select UPPER(name) 大写 from plays




select INITCAP(name) from plays //oracle 才有INITCAP这个函数 首字母大写 其他小写


select length(pay) from plays
where pay in( '2000' , ' 5000')


select RoUND(pay,-2) 百位四舍五入
from plays


select (getdate()-starttime) as 任期
from plays
where id =5

create table player( pid int not null primary key ,
pname varchar(20),
p_cid int not null ,
ptime date default sysdate,
foreign key (p_cid) references play(cid))


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值