Oracle认证 百分网手机站

ORACLE数据库操作基本语句

时间:2017-06-21 14:51:02 Oracle认证 我要投稿

ORACLE数据库操作基本语句

  Oracle数据库产品为财富排行榜上的'前1000家公司所采用,许多大型网站也选用了Oracle系统。下面是小编收集的关于ORACLE数据库操作基本语句,希望大家认真阅读!

  1.登陆SPL*PLUS

  [username/password] [@server] as [sysdba|sysoper]

  eg. system/password or connect sys/password as sysdba

  2.查看登录用户

  show user

  dba_users

  desc dba_users//展示表结构

  select username from dba_users;

  3.解锁用户

  alter user username account unlock

  4.表空间

  数据库--->表空间--->数据文件

  表空间分类:

  永久表空间: 表、视图,永久保存

  临时表空间: 操作当中的过程,过程结束即被释放

  UNDO表空间: 保存事务所修改数据的旧址,就是被修改之前的数据,用于回滚

  5.创建表空间

  create [temporary] tablespace tablespace_name tempfile|datafile 'xx.dbf' size xx

  永久表空间

  create tablespace test1_tablespace

  datafile 'testlfile.dbf' size 10m;

  临时表空间

  create temporary temptest1_tablespace

  tempfile 'tempfile1.dbf' size 10m;

  改变表空间状态

  alter tablespace tablespacename offline|online;联机||脱机

  alter tablespace tablespacename read only|read write;

  6.增加/删除数据文件

  增加

  alter tablespace tablespace_name add datafile 'xx.dbf' size xx;

  删除

  alter tablespace tablespace_name drop datafile 'xx.dbf';

  7.表

  (1)基本存储结构

  (2)二维结构

  (3)行和列

  8.数据类型

  字符型

  char(n) n<=2000 补充为n位

  nchar(n) n<=1000

  varchar2(n) n<=4000

  nvarchar2(n)n<=2000

  数值型

  number(p,s) p有效数字,s小数点后的位数

  float(n)

  日期型

  data

  timestamp

  其他类型

  blob 4GB二进制

  clob 4GB字符串

  9.管理表

  创建表

  create table table_name

  (

  colimn_name datatype, ...

  )