1、建表:
create table tableName
(
field field_type(length),
);
其中:field为字段名称; field_type为字段类型,一般有VARCHAR(),CHAR(),VARCHAR2(),LONG,Number( ,) 等等
2、查询:
select username,password from dba_users;//查询用户和密码
select * from dba_ustats;//查询系统所有用户信息
select * from user_users;//查看当前用户信息
select * from all_users;//查看所有用户信息
select * from dba_tab_privs;//查询系统所有用户对象权限
select * from all_tab_privs;//查看当前用户对象权限
select * from user_tab_privs//;查看所有用户对象权限
select * from dba_varrays;//查询用户可以访问的视图文本(好多数据)
select * from dba_views;//查询数据库中所有视图的文本(好多数据)
select ID from table;//ID指表中的字段,table指表的名称;
select table_name from user_tables;
select tablespace_name from user_tablespaces;
3、修改表的字段
alter table emp add (num varchar2(10));//往表emp中增加varchar2类型的字段num
alter table emp modify (num number);//将表中的num字段的类型更改为number类型;
alter table emp drop COLUMN num;//将表中的num字段去除掉;
4、修改表中的某条或某个数据;
update emp set num ='30' where id = '0';//修改表emp中的id为0的num字段值为30;
5、删除表中的某一行数据:
delete from emp where num = '30';//删除num=30的那一行数据;
6、往表里插入一条数据:
insert into emp (id,num)
values('4','50');//往表emp中插入一条id=4,num=50的数据;
7、删除表:
drop table emp;//删除表emp
8、重命名表的名称:
rename emp to re_emp;//将表名为emp更改成为re_emp
9、添加表的注释:
comment on table emp is 'this is emp's comment';//表的注释为:this is emp's comment