SQL Window - oracle 与 MySQl的学习笔记(一)
来源:互联网 发布:如何隐藏域名注册信息 编辑:程序博客网 时间:2024/05/17 02:46
-----------------------------alter的使用
--oracle
create table zpf(id number,name varchar(12),sex char(2) default 'W');
--mysql
create table zpf(id numeric,name varchar(12),sex enum("M","W") default 'W');
---oracle增加列
alter table zpf add (id2 varchar2(2));
alter table zpf add id2 varchar2(2);
--mysql
alter table zpf add ( id2 int);
alter table zpf add id3 int;
--oracle 删除列
alter table zpf drop column id2;
--mysql
alter table zpf drop column id2;
alter table zpf drop id2;
--oracle 修改列的类型
alter table zpf modify(id varchar2(2));
alter table zpf modify id varchar(2)
--mysql
alter table zpf modify id varchar(2);
alter table zpf change id id tinyint;
--oracle 重命名 表
alter table zpf2 rename to zpf;
--mysql
alter table zpf rename to zpf2;
alter table zpf rename zpf2;
--oracle 重命名 列
alter table zpf rename column id2 to id3;
--mysql
alter table zpf change id id4 int;
---oracle删除表
drop table zpf;
--mysql
drop table zpf;
drop table if exists zpf;
-------------------------------insert 的使用
select * from zpf;
---制定字段插入
insert into zpf(id,name)values(1,'zhangpf');
insert into zpf(id,name,sex)values(1,'zhangpf','M');
--默认全部插入
insert into zpf values(1,'zhangpf','M');
--mysql特殊
insert into zpf(id,name)values(1,'zhangpf'),(2,'liqiqi');--可以同时插入多条数据
insert into zpf set name='hjt';
--引用先前设置的值
--准备数据
--oracle
alter table zpf add age number;
alter table zpf rename column id2 to age2;
update zpf set age=2 where sex='W';
update zpf set age=3 where sex<>'W';
--mysql
alter table zpf add age int;
alter table zpf change id2 age2 int;
update zpf set age=2 where sex='W';
update zpf set age=3 where sex<>'W';
--mysql
insert into zpf(id,age2)values(3,id*3); --允许
insert into zpf(id,age2)values(age2*3,3); --不允许,得不到想要的结果,前面字段插入空值
--oracle不支持这个方式的插入
--子查询插入数据insert into 。。。。select 。。。
--oracle
create table zpf2 as select * from zpf where 1=2;
select * from zpf2;
insert into zpf2 select * from zpf;
insert into zpf2(id,name) select id,name from zpf where sex='W';
--mysql
create table zpf2 as select * from zpf where 1=2;
create table zpf2 select * from zpf where 1=2; --建表时mysql的AS关键字可有可无
insert into zpf2 select * from zpf;
insert into zpf2(id,name) select id,name from zpf where sex='W';
-------------------load的使用
create table zpf3 as select * from zpf where 1=2;
--mysql
--在设置了唯一键的情况下
load data local infile 'C:/ini.txt' into table zpf3 fields terminated by ',' enclosed by '' lines terminated by '\n'; --不考虑键值,仅是添加
load data local infile 'C:/ini.txt' replace into table zpf3 fields terminated by ',' enclosed by '' lines terminated by '\n';--唯一键相同情况下,更新此键数据
load data local infile 'C:/ini.txt' ignore into table zpf3 fields terminated by ',' enclosed by '' lines terminated by '\n';--唯一键相同情况下,不更新此键数据
--未设置唯一键时,效果都一样
--oracle 不再叙述 (sqlload的使用)
- SQL Window - oracle 与 MySQl的学习笔记(一)
- Window 学习笔记(一)
- ExtJS4学习笔记(一)---window的创建
- ExtJS4学习笔记(一)---window的创建
- ExtJS4学习笔记(一)---window的创建
- ORACLE PL/SQL 集合学习笔记(一)
- Oracle PL/SQL学习笔记(一)
- MySQL学习笔记(一)--SQL语句
- MySql 学习笔记一:SQL语句优化
- 学习ORACLE的笔记一
- 【Oracle】SQL语句与SQL函数(笔记一)
- python 与 mysql 学习笔记一
- 包子的 oracle 学习笔记---SQL学习
- SQL 与MYSQL与SQL SERVER与ORACLE的关系
- Oracle的学习一:安装与卸载、sql *plus常用命令、Oracle用户管理
- SQL\Oracle\MySql学习
- oracle sql学习一
- Oracle与MySQL的SQL语句区别
- adb常用命令总结
- plsql无法连接linux下的oracle服务器,提示:ora-12541:TNS 无监听程序
- <五>初始化
- java中汉字转换成拼音
- 父窗口与拥有者窗口
- SQL Window - oracle 与 MySQl的学习笔记(一)
- ASP.NET导出Excel或Word文件格式
- 一个java工程,可以有几个main方法
- CAN总线协议
- linux上线性回归 Gnuplot
- 打造增强用户体验的图片缓存方案(包含OOM处理技术)
- android更新桌面小插件widget的imageview时 出现!!! FAILED BINDER TRANSACTION !!!错误
- Java桌面程序打包成exe可执行文件
- 火狐浏览器强大的组件 firebug