oraclesql语法
sql语句基本相同,各厂商有自己新加语句,相似功能不同实现方法,所以某些语句有不同。
㈡ oracle 视图sql语句怎么写
方法和详细的操作步骤如下:
1、第一步,通过pl
/ sql登录到oracle数据库,见下图,转到下面的步骤。

㈢ oracle sql与标准的sql语句的区别
基本上都大同小异,只是在做外连的时候有些不一样,还有就是有几个函数不一样,其余的SQL语句都差不多,我也是才在看SQL的。Oracle与SQLServer还有个区别就是Oracle中当前用户只能访问它自己的数据表,别个用户建立的数据表无法访问到。
㈣ oracle如何检查sql语法错误
如果只是处于检查语法,可以在sql的where中拼上 and 1=2
或者用DBMS_SQL.PARSE
㈤ Oracle sql语法
参考网上资料,整理Oracle sql语法:
DDL:
1、创建表
create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)
根据已有的表创建新表:
create table tab_new as select col1,col2… from tab_old
2、删除表
drop table tabname
3、重命名表
说明:alter table 表名 rename to 新表名
eg:alter table tablename rename to newtablename
4、增加字段
说明:alter table 表名 add (字段名 字段类型 默认值 是否为空);
例:alter table tablename add (ID int);
eg:alter table tablename add (ID varchar2(30) default '空' not null);
5、修改字段
说明:alter table 表名 modify (字段名 字段类型 默认值 是否为空);
eg:alter table tablename modify (ID number(4));
6、重名字段
说明:alter table 表名 rename column 列名 to 新列名 (其中:column是关键字)
eg:alter table tablename rename column ID to newID;
7、删除字段
说明:alter table 表名 drop column 字段名;
eg:alter table tablename drop column ID;
8、添加主键
alter table tabname add primary key(col)
9、删除主键
alter table tabname drop primary key(col)
10、创建索引
create [unique] index idxname on tabname(col….)
11、删除索引
drop index idxname
注:索引是不可更改的,想更改必须删除重新建。
12、创建视图
create view viewname as select 语句
13、删除视图
drop view viewname
14. 创建表空间
create tablespace schooltbs datafile ‘D:\oracle\datasource\schooltbs.dbf’ size 1000M autoextend on;
15. 删除表空间
drop tablespace schooltbs[including contents and datafiles];
注:查询表空间和表空间存储路径
SELECT * FROM dba_data_files WHERE tablespace_name = 表空间名;
DML:
1、数据查询
select <列名> from <表名> [where <查询条件表达试>] [order by <排序的列名>[asc或desc]]
2、插入数据
insert into 表名 values(所有列的值);
insert into test values(1,'zhangsan',20);
insert into 表名(列) values(对应的值);
insert into test(id,name) values(2,'lisi');
3、更新数据
update 表 set 列=新的值 [where 条件] -->更新满足条件的记录
update test set name='zhangsan2' where name='zhangsan'
update 表 set 列=新的值 -->更新所有的数据
update test set age =20;
4、删除数据
delete from 表名 where 条件 -->删除满足条件的记录
delete from test where id = 1;
delete from test -->删除所有
commit; -->提交数据
rollback; -->回滚数据
delete方式可以恢复删除的数据,但是提交了,就没办法了 delete删除的时候,会记录日志 -->删除会很慢很慢
truncate table 表名
删除所有数据,不会影响表结构,不会记录日志,数据不能恢复 -->删除很快
drop table 表名
删除所有数据,包括表结构一并删除,不会记录日志,数据不能恢复-->删除很快
5、数据复制
表数据复制
insert into table1 (select * from table2);
复制表结构
create table table1 select * from table2 where 1>1;
复制表结构和数据
create table table1 select * from table2;
复制指定字段
create table table1 as select id, name from table2 where 1>1;
㈥ oracle 中SQL 语句开发语法 SELECT INTO含义
和sqlserver的不一样
sqlserver或者access中select into 是通过查询数据来建表
oracle中,这个select into不能在语句中执行,必须要放到存储过程,函数等等里边执行
譬如select to_char(sysdate,'yyyy-mm-dd') into v_date from al;
这个v_date是用来放变量的,在后续的过程中来调用这个变量
但是这个一次只能放一个值,如果值过多的话需要用到游标
你说的非维护语法是啥意思啊?你要有不懂的可以继续问,但是资料的确不多,都是自己写的被我放论坛上了
㈦ oracle中sql语句的写法
oracle中没有limit,mysql的limit 0,1在oracle中的等价语句是rownum<=1.
㈧ oracle统计查询 sql语句应该怎么写
select
substrb(create_time,1,4)
"年份",
sum(decode(substrb(create_time,6,2),'01',commission,0))
"1月",
sum(decode(substrb(create_time,6,2),'02',commission,0))
"2月",
sum(decode(substrb(create_time,6,2),'03',commission,0))
"3月",
sum(decode(substrb(create_time,6,2),'04',commission,0))
"4月",
sum(decode(substrb(create_time,6,2),'05',commission,0))
"5月",
sum(decode(substrb(create_time,6,2),'06',commission,0))
"6月",
sum(decode(substrb(create_time,6,2),'07',commission,0))
"7月",
sum(decode(substrb(create_time,6,2),'08',commission,0))
"8月",
sum(decode(substrb(create_time,6,2),'09',commission,0))
"9月",
sum(decode(substrb(create_time,6,2),'10',commission,0))
"10月",
sum(decode(substrb(create_time,6,2),'11',commission,0))
"11月",
sum(decode(substrb(create_time,6,2),'12',commission,0))
"12月"
from
test
group
by
substrb(create_time,1,4)
此语句是按create_time字段是字符型给出的,如果你的表中此字段是日期型,则进行一下转化
㈨ sqlserver和oracle sql语法的区别
sqlserver和oracle 对应两种sql优化版本分别是T-SQL和PL-SQL
标准sql语法都兼容,比如子查询那些,区别就是函数使用方式而已。
isnull 与 nvl
row_number() over 与 rownumber()
ceiling 与 ceil
log 与 ln
SQUARE 与 power
+ 与 ||
substring 与 substr
Len 与 length
getdate 与 sysdate
以上等等都是同功能的函数
当然也存在同名函数参数顺序不同的情况,就不一一列出来了。
㈩ oracle sql语法 ①中的:1代表什么;②中声明的变量类型是什么;③中的赋值语法是什么
1. 这是一个绑定变量的标准写法,:1可以理解为一个占位符。OLTP系统里面使用这种绑定变量的写法可以减少硬解析的次数,减少对数据字典以及Latch的使用,单个语句上提升的不大,但是对于整体性能有很大的提升。
2. 声明了一个number数组类型num_list,其最大存储number元素的个数为20。java里面类似于int[20]。
3. 声明变量v_id 类型为num_list,并且初始化变量v_id的第一、二个element为100,101。
