四时宝库

程序员的知识宝库

oracle常用(oracle常用函数大全)

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

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言
    友情链接