oracle学习笔记

1.oracle实例服务:oracleServiceXXX
2.oracle监听服务:oracleoradb11g_home1TNSListener
3.登录:sqlplus sys/sys as sysdba;
4.显示表结构命令:desc tableName;
5.查询所有用户名:select username,default_tablespace from dba_users;
6.默认表空间:USERS,TEMP,SYSTEM,SYSAUX,UNDOTBS1
7.切换用户命令:CONNECT USERNAME/PASSWORD;
8.显示当前用户:SHOW USER;
9.启动数据库:STARTUP;
10.关闭数据库:SHUTDOWN;
11.DBA_ALL_TABLES存放所有表的信息。
12.查询数据库文件:select file_name,tablespace_name from dba_data_files;
13.查询日志文件:SELECT * FROM V$LOGFILE;
14.查询所有表空间:select tablespace_name from dba_tablespaces;
15.创建表空间:
   create tablespace test
   datafile 'D:\oracle\oradata\orcl/test.dbf'   
   size 1500M  autoextend on next 50M maxsize 3000M;

   create tablespace emr   
   datafile 'E:/oracle_tablespaces/DEMOSPACE_TBSPACE.dbf'   
   size 1500M  autoextend on next 50M maxsize UNLIMITED;
16.查询数据库文件路径:select name from v$datafile;
17.创建用户:create user test identified by test default tablespace test
18.给用户授权:grant connect, resource to emr; grant dba to emr;
19.指定用户的表空间:alter user emr default tablespace emr_tablespace;
20.导入DMP文件:imp emr/emr@orcl  file=C:\mandala.dmp full=y ignore=y;
21.修改字符集命令:
ALTER DATABASE character SET ZHS16GBK; 
ALTER DATABASE character set INTERNAL_USE ZHS16GBK; 
22.查询字符集
select userenv('language') from dual;
23:创建序列
create sequence SEQ_FJ_JYJL
minvalue 1
maxvalue 9999999999999999999999999999
start with 1
increment by 1
nocache;
24:创建触发器
create or replace trigger tr_fj_jcjl
before insert on fj_jcjl
for each row
begin
select SEQ_FJ_JYJL.nextval into :new.xh from dual;
end;
25.to_date函数用法: to_date(入院日期,'YYYY-MM-dd hh24:mi:ss')
26.如果想设置密码不过期,可用管理员登陆,然后执行:ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
27.TO_DATE('2022-02-17','yyyy-MM-dd')
28.修改密码:alter user 用户名 identified by 新密码;
29.修改数据库字段
30.创建数据库链接
create database link databaseLinkName
connect  to  userName
identified by password
using databaseServiceName
15、使用身份证号转换为出生日期;
select to_date(substr(p.card_code,7,8),'YYYY-MM-DD') 
from  PAT_IMP_INPATIENT_LIST  p
建索引
alter table VOAMASTM add constraint PK_VOAMASTM primary key(REFCODE) using index tablespace users;

你可能感兴趣的:(oracle,学习,数据库)