专业编程教程与实战项目分享平台

网站首页 > 技术文章 正文

oracle常用 oracle常用函数大全

ins518 2024-10-17 13:03:56 技术文章 18 ℃ 0 评论

1. 复制空表结构

create table new_table
as select * from old_table where 1=2;

复制表(含记录)

create table new_table
as select * from old_table ;

2. 修改表的结构

alter table table_name rename column age to age1;  修改字段名
alter table old_table_name rename to new_table_name;修改表名
alter table student add scome date;增加一个列.
alter table student modify sage int;将年龄的数据类型改为整数.
alter table student drop unique(sname);删除学生姓名必须取唯一值的约束.

----nvl

nvl('',10)=10
nvl(null,10)=10
nvl(20,10)=20


---字符串的连接

SELECT CONCAT(COL1,COL2) FROM TABLE ;
SELECT COL1||COL2 FROM TABLE ;

--怎样把“&”放入一条记录中?

insert into a values (translate ('at{&}t','at{}','at'));

1.单引号的插入问题

SQL> insert into a values('I''m good'); --两个''可以表示一个',//I’m good.
SQL> insert into a values('I'||chr(39)||'m good');--chr(39)代表字符' //I’m good.
SQL> insert into a values('a'||'&'||'b'); //表示a&b

--取出一个表的最后一条记录

select * from
(select rownum id,table_name.*
from table_name
) a
where a.id=(select count(*) from table_name);

2021-7-29

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表