標籤:
一、資料庫基本操作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常用命令和資料類型