同事shirly和alan整理
MySQL |
Oracle |
Note |
int/double |
number |
数值型 |
varchar |
varchar2 |
小文本型 |
text |
varchar2 |
对于普通文本大于255,且小于4000的列 |
text |
blob |
对于comment |
longblob |
blob |
|
create table tableName(
columnName1 int,
columnName2 int
)
MySQL:
drop table if exists tableName
Oracle:
drop table tableName
注:Oracle没有if exists关键字,也没用类似if exists的SQL语法。
MySQL:
A.altertable tableName add columncolumnName1 int;
B.alter tabletableName add column columnName1 int, add column columnName2int;
注:其中关键字column可有可无。
Oracle:
A.alter tabletableName add columnName1 int;
B.alter tabletableName add (columnName1 int);
C.alter tabletableName add (columnName1 int, columnName2 int);
注:对于A,只有添加单列的时候才可使用,对于添加多列时需要使用C,不能像MySQL那样重复使用add column关键字。
MySQL:
A.alter tabletableName drop column columnName1
B.alter tabletableName drop column columnName1, drop column columnName2
注:其中关键字column可有可无。
Oracle:
A.alter tabletableName drop column columnName2
B.alter tabletableName drop (columnName1)
C.alter tabletableName drop (columnName1,columnName2)
注:对于A,只有删除单列的时候才可使用,对于删除多列时需要使用C,不能像MySQL那样重复使用drop column关键字。
MySQL:
alter tabletableName change column columnNameOldcolumnNameNew columnType;
Oracle:
alter tabletableName rename column columnNameOld tocolumnNameNew;
A.MT中修改列的类型并非使用SQL语句进行一步到位的修改,而是通过以下流程:
B.添加临时列
C.将需要更改的列的值经过类型转换的验证后,赋值给临时列
D.删除原有列
E.将临时列的列名修改为原有列列名
在整个数据库内,MySQL的索引可以同名,也就是说MySQL的索引是表级别的;但是Oracle索引不可以同名,也就是说Oracle的索引是数据库级别的。
create indexindexName on tableName (columnName);
MySQL:
alter tabletableName drop index indexName
Oracle:
drop indexindexName
MySQL:
show index fromtableName
Oracle:
select index_name, table_name,column_namefrom user_ind_columns where table_name=' tableName '
Oracle用户名解锁
Alter userscottaccount unlock;
授权用户
Grant connect ,resource,create session,create view toscott;
创建用户
Create user sha indetifiedby admin 用户名:sha密码:admin
修改用户system密码为manager
SQL> alter user systemidentified by manager;