为了账号安全,请及时绑定邮箱和手机立即绑定
慕课网数字资源数据库体验端
Oracle数据库开发必备利器之SQL基础_学习笔记_慕课网
为了账号安全,请及时绑定邮箱和手机立即绑定

Oracle数据库开发必备利器之SQL基础

AnnyQin
难度入门
时长 4小时14分
  • 创建表 CREATE TABLE table_name ( column_name datatype,... ); eg: create table userinfo ( id number(6,0), username varchar2(20), userpwd vachar2(20), email vachar2(30), regdate date); desc userinfo//查看表结构
    查看全部
    0 采集 收起 来源:Oracle管理表

    2016-07-30

  • 表中的数据类型 1、字符型 CHAR(n)--MAX2000自动补齐后面的空格、NCHAR(n)--MAX1000 VARCHAR2(n)--MAX4000可变长度不用补齐后面的空格、NVARCHAR2(n)--MAX2000 2、数值型 NUMBER(p,s)--p有效数字,s小数点后的位数 FLOAT(n)--存储二进制的位数 3、日期型 DATE--DATE类型表示范围:公元前4712年1月1日到公元9999年12月31日,可以精确到秒 TIMESTAMP--时间戳类型,精确到小数秒 4、其它类型(大对像) BLOB--存放4GB的数据,以二进制 CLOB--存放4GB的数据,以字符串
    查看全部
  • 认识表 1、表是基本存储单位 2、二维结构 3、行和列 约定 1、每一列数据必须具有相同数据类型 2、列名唯一 3、每一行数据的唯一性
    查看全部
  • 二、表空间 1、表空间概述 1.一个数据库由多个表空间构成,一个表空间由多个数据文件构成 2.表空间分为:永久表空间、临时表空间、UNDO表空间 2、查看用户表空间 1.查看用户的表空间 select tablespace_name from dba_tablespaces | user_tablespaces; select default_tablespace,temporary_tablespace from dba_users | user_users where username='XXX'; 2.设置用户的默认或临时表空间 alter user username default | temporary tablespace tablespace_name; 3、创建、修改、删除表空间 1.创建表空间 create [temporary] tablespace tablespace_name tempfile | datafile 'xx.dbf' size xx ; select file_name from dba_data_files | dba_temp_files where tablespace_name='XXX'; 2.修改表空间 (1)设置联机或脱机状态 alter tablespace tablespace_name offline | online; (2)查看表空间状态 select status from dba_tablespaces where tablespace_name='XXX'; (3)设置只读或者可读写状态 alter tablespace tablespace_name read only(只读) | read write(读写); (4)修改表空间中的数据文件 添加数据文件 alter tablespace tablespace_name add datafile 'xx.dbf' size xx; 删除数据文件 alter tablespace tablespace_name drop datafile 'filename.dbf'; 3.删除表空间: drop tablespace tablespace_name [including contents];
    查看全部
  • 用户与表空间 一、用户 1、登录SQL Plus (1)系统用户 1.sys> system 2.sysman 3.scott(默认密码tiger) (2)使用系统用户登录 [username/password] [@sever] [as sysdbasysoper] //sys权限必须是sysdba或sysoper 2、查看登录用户 1.查看登录用户:show user 2.通过数据字典查看登录用户 查看数据字典:desc dba_users 查看用户:select username from dba_users; 3、启用scott用户 alter user scott account unlock; //启用scott用户 connect scott/tiger; //使用scott用户登录SQL Plus
    查看全部
  • 删除表空间: drop tablespace tablespace_name [including contents];
    查看全部
  • 更改system用户默认表空间的语句 alter user system default tablespace xxx
    查看全部
    0 采集 收起 来源:练习题

    2016-07-30

  • 数据文件 1.添加数据文件 alter tablespace tablespace_name add datafile 'xx.dbf' size xx; 2.删除数据文件 alter tablespace tablespace_name drop datafile 'filename.dbf'; //不能删除表空间的第一个数据文件,要删除的话,必须删除整个表空间 eg: alter tablespace test1_tablespace add datafile 'test2_file.dbf' size 10m; select file_name from dba_data_files where tablespace_name='TEST1_TABLESPACE'; alter tablespace test1_tablespace drop datafile 'test2_file.dbf';
    查看全部
  • dba_users:用于查看数据库信息。 语法:SQL>desc dba_users;
    查看全部
  • 查看登录用户:show user
    查看全部
  • Oracle 数据库中scott用户的权限最低。
    查看全部
    0 采集 收起 来源:练习题

    2016-07-30

  • scott 用户默认的密码为tiger
    查看全部
  • 修改表空间的状态 1.设置联机或脱机状态 alter tablespace tablespace_name offline online; //脱机状态是不能使用的 2.查看表空间状态 select status from dba_tablespaces where tablespace_name='xxx'; //表空间名字要大写 3.设置只读或者可读写状态(表空间必须为联机状态,联机状态默认为读写状态): alter tablespace tablespace_name read only(只读)read write(读写); eg: alter tablespace test1_tablespace offline; desc dba_tablespaces; select status from dba_tablespaces where tablespace_name='TEST1_TABLESPACE'; alter tablespace test1_tablespace read only; select status from dba_tablespaces where tablespace_name='TEST1_TABLESPACE';
    查看全部
  • 1.创建表空间 create [temporary] tablespace tablespace_name tempfile | datafile 'xx.dbf' size xx //temporary表示临时表空间 不指定路径,默认安装到oracle安装目录下 eg: create tablespace test1_tablespace datafile 'test1file.dbf' size 10m; //创建默认表空间 create temporary tablespace temptest1_tablespace tempfile 'temptest1file.dbf' size 10m; //创建临时表空间 2.查看表空间具体路径 查看数据字典字段 : desc dba_data_files desc dba_temp_files select file_name from dba_data_file where tablespace_name='表空间名字要大写'; //查看永久表空间数据文件 select file_name from dba_temp_file where tablespace_name='表空间名字要大写'; //查看临时表空间数据文件 eg: desc dba_data_files select file_name from dba_data_files where tablespace_name='TEST1_TABLESPACE'; desc dba_temp_files select file_name from dba_temp_files where tablespace_name='TEMPTEST1_TABLESPACE';
    查看全部
  • case...when语句的使用 基本语法:([when后面跟的是判断的条件,then是条件为真是显示出来的东西]) 语法1:CASE column_name WHEN value1 THEN result1, ... [ELSE resultn] END; 语法2:CASE WHEN column_name=value1 THEN result1, ...[ELSE resultn] END; 注:value1、result1需要加单引号,表示字符串,当多个when...then...使用时,中间用空格隔开即可,不能用逗号隔开。第二种是采取表达式的形式也可以用><=
    查看全部
    0 采集 收起 来源:case...when语句

    2018-03-22

举报

0/150
提交
取消
课程须知
只要知道数据库是什么就可以来学习本课程呦!
老师告诉你能学到什么?
掌握Oracle的SQL语句基础,为后续的课程学习打好基础。
友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!