ORACLE學習03-SQLPLUS常用命令和資料類型

來源:互聯網
上載者:User

標籤:

一、資料庫基本操作1,建立使用者    SQL> create user 使用者名稱 identified by 密碼;2,超級使用者system給新使用者權限    SQL> grant    connect   ,      resource        to  mike;         授權     串連許可權        增刪改查許可權3,新使用者登入,進入新使用者的空間    SQL> connect mike/m111;4,顯示目前使用者    SQL>show user;5,建表,添加資料,增刪改查。 6,登入sqlplus>sqlplus 登入名稱/密碼@127.0.0.1:1521/資料庫執行個體名 二、Oracle資料類型1, 字元型:varchar2            --等價於varchar,可變長,最多4000位元組varchar2(10)        --用於儲存固定長度,在磁碟中存放的就是‘abcd‘char                --定長,最多1000位元組。char(10)            --用於存放固定長度,在磁碟中存放的是‘abcd‘。注意:一個漢字佔3個位元組 create table student(name varchar2(32))2, 數值型:number             --38位精度。number(6)         --表示整數:6位。number(6,2)        --表示小數:總共6位,其中小數佔2位。3, 日期型:date當前日期:sqlserver--getdate() Oracle--sysdate日期格式:用to_date()函數控制時間格式SQL> insert into person(id,name,sex,logindate) values(10003,‘張三‘,‘男‘,to_date(‘1998-12-25‘,‘yyyy-mm-dd‘));4, 大對象:儲存圖片,視頻,檔案。<2gblob     -- 二進位大對象clob     -- 字元型大對象 三、常用命令析describe 表名                    --查看錶結構select * from tab;           --查看目前使用者的所有表drop table 表名;              --刪除表drop user 使用者名稱 cascade;    --刪除使用者 四、練習C:\Documents and Settings\Administrator>sqlplusSQL*Plus: Release 10.2.0.1.0 - Production on 星期六 12月 24 10:34:35 2011Copyright (c) 1982, 2005, Oracle. All rights reserved.請輸入使用者名稱: system輸入口令: 串連到:Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production SQL> create user sunnybug identified bym123;使用者已建立。 SQL> grant connect,resource to sunnybug;授權成功。 SQL> connect sunnybug/m123;已串連。 SQL> show user;USER 為 "sunnybug" SQL> connect system/m123;已串連。 SQL> show user;USER 為 "SYSTEM" SQL> drop user sunnybug cascade;使用者已刪除。 SQL> connect sunnybug/m123;ERROR:ORA-01017: invalid username/password; logon denied 

 

ORACLE學習03-SQLPLUS常用命令和資料類型

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.