基本语法
insert into 表名 values (值1,值2.。。。);<Oracle和MySQL>
insert into t_student values(idvalue,namevalue);<批量插入>
insert into t_student values(idvalue,namevalue),(idvalue,namevalue);<利用查询语句插入>
insert into t select id from t_student;!!!
如果数据为空,则插入null时间类型用单引号插入 例 birthdate=‘1998-08-04’基本语法
update 表名 set 列名=修改的值 where 列名=被修改的值<Oracle 和 MySQL>
update t_student set id=8 where id=1;基本语法
delete from 表名 where 列名=值<Oracle 和 MySQL>
delete from t_student where id=3;基本语法
select 列名1,列名2.。。。from 表名 where 条件 group by 条件 having 筛选条件 order by 顺序基本语法(标准创建)
create table 表名(列名 类型(列宽)[约束],列名 类型(列宽)[约束]...);<Oracle 和 MySQL>
create table t(id int primary key unique);注意:1.类型有点差异 MySQL整型是int ,Oracle是number
2. 类型有点差异 MySQL字符型是varchar ,Oracle是varchar2
基本语法(快速创建)
CREATE TABLE 表名 AS 查询语句 ;//字段和数据都会复制,相当于表的复制<Oracle 和 MySQL>
create table tt as select * from t_student;基本语法
drop table 表名;<Oracle 和 MySQL>
drop table t_student;< MySQL>
基本语法
rename table 原表名 to 新表名;实例:
rename table t to tt;基本语法:
alter table 原表名 rename to 新表名 rename 原表名 to 新表名;实例:
alter table t rename to tt rename table t to tt;注意:改表名的方式均不相同
< MySQL>
基本语法
show tables;
基本语法:
select table_name from user_tables;基本语法
desc 表名;<Oracle 和 MySQL>
desc t_student;基本语法
truncate table 表名<Oracle 和 MySQL>
truncate table t_student;< MySQL>和
基本语法
alter table 表名 add(列名 类型(列宽))实例:
alter table tt add(name varchar(10));< MySQL>和
基本语法
alter table 表名 rename column 原列名 to 新列名实例:
alter table tt rename column ename to youname;基本语法
alter table 表名 modify(列名 类型(宽度))实例:
alter table tt modify ( name varchar2(30));< MySQL>
基本语法
alter table 表名 modify 列名 类型(宽度)实例:
alter table tt modify name varchar2(30);注意:两者之间细微差距:Oracle带括号,MySQL不带括号
< MySQL>和
基本语法
alter table 表名 drop 列名;实例:
alter table tt drop myname;基本语法
alter table 表名 drop column 列名;实例:
alter table tt drop column myname;注意:两者细微差别:Oracle添加了column ,MySQL没有
事务就是一组SQL语句,要么同时发生,要么同时不发生。
是构成单一逻辑工作单元的操作集合
MySQL:
1. read uncommitted 2. read committed 3. repeatable read 4. serializable[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-3ilVP9Do-1603187762871)(D:\applications\GoogleChrome-80.0.3987.106-Windows-64bit\shiwu.png)]
据库从一个一致性状态到另一个一致性状态。
隔离性:并发执行的事务不会相互影响,其对数据库的影响和它们串行执行时一样。持久性:事务一旦提交,其对数据库的更新就是持久的。任何事务或系统故障都不会导致数据丢失。 MySQL:
1. read uncommitted 2. read committed 3. repeatable read 4. serializable[外链图片转存中…(img-3ilVP9Do-1603187762871)]