-- 修改Oracle数据库中用户密码:
① 进入cmd命令窗口;
② 通过 “sqlplus/nolog” 命令进入SQL;
③ 通过 “conn system/xxxxxx;” 命令进入system用户:数据库系统管理员用户;【xxxxxx为自己数据库系统管理员用户密码】
④ 通过 “select username from dba_users;”可以查询系统下,所有用户名;【若是修改已知名称用户密码,此步骤可省略】
⑤ 通过 “alter user 用户名 identified by 新密码;” 进行用户密码修改操作;
-- 查看某表属于哪个用户 [根据数据表名称查询其归属]:
-- Note:因为Oracle数据库所有表名都是大写格式,所以这里的表名称应是大写格式!!
-- 此sql操作只作用在system(数据库系统管理员)用户下;【在已知用户下将失去意思】
select owner from dba_tables where table_name=upper('emp');
select owner, table_name from all_tables where table_name=upper('emp');
或者
select owner from dba_tables where table_name='EMP';
select owner, table_name from all_tables where table_name='EMP';
-- 查看Oracle 数据库中当前用户下的所有用户创建的数据表名称 :
select table_name from user_tables;
-- 查看Oracle 数据库中当前用户下所有数据表名称 :
select user,table_name from all_tables;
-- 查看Oracle 数据库中本用户下的所有列 :
select table_name,column_name from user_tab_columns;
-- 查看Oracle 数据库中本用户下的所有列 :
select user,table_name,column_name from all_tab_columns;
-- 查看Oracle 数据库中的序列号 :
select * from user_sequences;
上面的所有对象,都可以通过下面的SQL语句查询得到
-- 查询当前用户创建的所有Oracle对象。包括:表对象、约束条件、索引、序列、存储函数、触发器 ...
select * from user_objects;
-- 查看Oracle 数据库中当前用户下所有表的注释 :
select table_name,comments from user_tab_comments;
-- 查看Oracle 数据库中当前用户所有数据表的所有列的注释 :
select table_name,column_name,comments from user_col_comments;
-- 查看Oracle数据库当前用户下,指定数据表的所有注释 :
select * from user_col_comments where table_name='EMP';
或者
select * from user_col_comments where table_name=upper('emp');
-- 给Oracle数据表添加注释 :
comment on table is '注释内容';
-- 给Oracle数据表中的指定列添加的注释 :
comment on column 表名.列名 is '注释内容';
-- 查看表中列的属性,包括 数据类型,是否非空等 :
desc 表名;
-- 查看表空间名称及大小 :
select t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
-- 查看未使用表空间大小
select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by tablespace_name;
-- 查看数据库中当前用户下的表、索引占用的数据库空间大小 :
select* from user_segments;
-- 统计当前用户下,所有数据表中的数据记录行数:
select t.table_name,t.num_rows from user_tables t;