–创建表空间
create tablespace itheima
datafile ‘c:\itheima.dbf’
size 100m
autoextend on
next 10m;
– 删除表空间
drop tablespace itheima;
–创建用户
create user itheima
identified by itheima
default tablespace itheima;
–创建表
create table person(
pid number(11),
name varchar2(10),
);
–添加一列
alter table person add (gender number(1));
–修改列类型
alter table person modify gender char(1);
–修改列名称
alter table person rename column gender to sex;
–删除一列
alter table person drop column sex;
– 添加一条记录
insert into person(pid,pname) values (1,‘小明’);
insert into person(pid,pname) values(2,‘小红’);
commit;
–查询
select * from person;
–修改
update person set pname=‘小马哥’ where pid=1;
commit;
–删除
delete from person;
drop table person;
truncate table person;–先删除,再创建一张空表
–序列 默认从1开始,依次递增
create sequence s_person;
select s_person.nextval from dual;
–添加
insert into person(pid,pname) values(s_person.nextval,‘大明’);
commit;