select substr('Hellowepull',2,3) from a;--截取从第2个字符开始的长度为3个字符的字符串
select substr('Hellowepull',2) from a;--截取从第2个字符开始的字符串
select substr(t.title,2) from tf_cms_webpage t;--截取某个字段从第2个字符开始的字符串
select chr(97) from a;--求一个与ASCII码值对应的字符
select ascii('a') from a;--求一个字符的ASCII码值
select to_char(2123,'L99,999.99') from a;--转换数字(to_char()用于将数字或日期转换成特定的字符串)
select to_char(sysdate,'YYYY-MM-DD HH24:MI:SS') from a;--转换时间(to_char()用于将数字或日期转换成特定的字符串)
select * from tf_cms_webpage t where t.createdate > to_date('2012-08-10 00:00:00','YYYY-MM-DD HH24:MI:SS');--to_date()是将特定的字符串转换成日期格式
select * from (select c.*, rownum rn from tf_cms_webpage c) where rn between 21 and 40--分页查询(特定格式)
--rownum只能使用<,<=,!=,<和!=结果是一样的
--group by使用规律:出现在select列表中的字段如果没有出现在聚合函数中,则必须出现在group by子句中
--复制表
--1.只复制表结构
create table b as select * from a where 1<>1;
--2.既复制表结构又复制表的数据
create table b as select * from a;
--3.复制表的指定字段
create table b as select n_id,n_name,n_age from a where 1<>1;
--4.复制表的指定字段及数据
create table b as select n_id,n_name,n_age from a;
--视图
--1.创建视图
create view book_view
as
select n_id,n_name,n_age from book join n_type on (book.n_name=n_type.name);
--2.使用视图查询
select * from book_view;
--3.修改视图
create or replace view booke_view
as
select n_id,n_name,n_age from book join n_type on (book.n_name=n_type.name);
--4.错误写法修改视图
alter view booke_view
as
select n_id,n_name,n_age from book join n_type on (book.n_name=n_type.name);
--5.删除视图
drop view book_view;--注意:对应的表的数据不会删除
oracle基本语句
最新推荐文章于 2025-08-15 20:46:11 发布