数据库的相关操作
1,修改表名:alter table oldname rename to newname;
2,向表中增添一列:alter table tablename add colunmname varchar2(10);
3,删除一张表: drop table tablename;
4,删除一张表中的所有数据:delete * from table_name;
5, 根据一张表的结构创建另一张相同的表:create table table_name as select * from table_name1;
6.如果只知道一个字段,要判断这个字段属于那张表:select table_name from dba_tab_columns where column_name = '字段名';
7.找出一张表中重复的字段:select cardnum ,count(*) from calink group by cardnum having count(*)>1;
如表A, 编号,经度,纬度,位置,名称,时间.
而我要查出(经度 +纬度)相同的记录来,可使用下边的语句.
Select distinct (经度+纬度) as 统一编号,Count(*) as RecordCount
From 表A
Group by (经度+纬度)
having Count(*) >1
问题:
SYS@HMX>desc dba_tablespaces;
ERROR:
ORA-04043: object dba_tablespaces does not exist
查询发现数据库处于mount阶段
SYS@HMX>select status from v$instance;
STATUS
------------------------
MOUNTED
打开数据库
SYS@HMX>alter database open;
Database altered.
依旧显示不存在
SYS@HMX>desc dba_data_files;
ERROR:
ORA-04043: object dba_data_files does not exist
查询其他视图存在
SYS@HMX>desc dba_objects;
Name Null? Type
------------------------------------------------------------------------ -------- -------------------
OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(128)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
原来是在mount阶段不能查询dba_* 视图,一旦在mount阶段查询过某个视图,即使open之后在查询,还是显示不存在的,这时候就只有重启数据库了