- 查看登录用户
show user;
- 启用scott用户
alter user scott account unlock;
- 操作表空间
select * from dba_tablespaces;
select * from user_tablespaces;
select * from dba_users;
select * from user_users;
alter user username default|temporary tablespace tablespace_name;
/*修改用户默认或临时表空间*/
create [temporary]tablespace tablespace_name tempfile|datafile 'xxx.dbf' size ;
/*创建永久或临时表空间*/
select * from dba_data_files|dba_temp_files where tablespace_name='tablespace_name';
/*查看以创建的表空间信息*/
alter tablespace tablespace_name offline|online;
/*设置表空间脱机或联机状态*/
alter tablespace tablespace_name read only|read write;
/*设置表空间读写状态*/
alter tablespace tablespace_name add datafile 'xxx.dbf' size ;
/*向表空间中增加数据文件*/
alter tablespace tablespace_name drop datafile 'xxx.dbf';
/*删除表空间数据文件*/
drop tablespace tablespace_name including contents;
/*删除表空间*/
- plsql连接用户
conn username/password@server
- 创建表
create table table_name(
id number(6,0) primary key,
username varchar2(20) not null,
userpwd varchar2(20) not null
);
alter table table_name add column_name datatype;
/*添加字段*/
alter table table_name modify column_name datatype;
/*修改字段数据类型*/
alter table table_name drop column column_name;
/*删除字段*/
alter table table_name rename column old_column_name to new_column_name;
/*修改字段名*/
rename table table_name to new_table_name;
/*修改表名*/
truncate table table_name;
/*截断表,删除表中数据*/
drop table table_name;
/*删除表*/
create table table1 as
select * from table2;
/*将table2中的数据复制到table1中,两个表结构相同*/
insert into table_new (column1,column2...)
select column1,column2.. from table_old;
/*复制其它表数据到新表中*/
insert into talbe_name(column1,column2...) values(value1,value2...);
create table(
id number(4,0),
regdate date default sysdate
);/*设置默认值*/
alter table user_name modify column default ' ';
/*修改默认值*/