1、Oracle 默認用戶
sys(維護系統(tǒng)信息和管理實例)
system(管理數(shù)據(jù)庫用戶、權(quán)限和存儲)
scott(示范用戶)
2、修改Oracle用戶名密碼

修改密碼三步曲
查看Oracle用戶
select user name from db a_users;
登錄system賬戶
conn system as sysdba
登錄scott賬戶
conn scott
解鎖scott賬戶

解鎖步驟
PL/SQL Developer中解鎖Scott用戶
用戶名為system,口令為安裝軟件時所設,連接為SYSDBA

第一步
找到User文件夾下的SCOTT

第二步
右鍵編輯取消“賬戶被鎖住”,應用

第三步
3、Oracle中創(chuàng)建數(shù)據(jù)庫
從Windows桌面執(zhí)行
→“開始”
→“程序”
→“Oracle - ”
→“配置和移置工具”
→“Database Configuration Assistant”命令,
打開Database Configuration Assistant對話框的歡迎界面,單擊該界面中的“下一步”按鈕

創(chuàng)建數(shù)據(jù)庫界面
4、Oracle數(shù)據(jù)類型
字符(char、varchar2、nvarchar)常用varchar2
數(shù)值(number[(p,[s])])p表示精度,s表示小數(shù)點的位數(shù)
日期和時間(DATE)存儲日期和時間部分,精確到整個的秒
5、Oracle與MySQL的不同之處
對比1:查詢與插入日期時間
Oracle中查詢時間只能用
select sys date from 表名;
MySQL中查詢時間
mysql>selectnow();mysql>selectcurrent_time();mysql>selectcurrent_date();mysql>selectcurrent_timestamp();mysql>selectsysdate();
Oracle中插入時間到表中
insert into c1 values(to_date('2008-12-16','yyyy-mm-dd'));
insert into c1 values(to_date('2008-12-26 16:29:28','yyyy-mm-dd hh24:mi:ss'));
Oracle中SYSDATE時間格式
標準格式為"YYYY-MM-DD HH(12/24):MI:SS"
MySQL中DATETIME時間格式
標準格式為"YYYY-MM-DD HH:MM:SS"
Oracle中指定時間格式
select to_char(jobtime,'yyyy-mm-dd')fromc1;

只顯示年月日
select to_char(jobtime,'yyyy-mm-dd hh24:mi:ss')from c1;

顯示年月日和時分秒
對比2:插入多條數(shù)據(jù)
Oracla中創(chuàng)建表
create table stu(idnumberprimarykey,namevarchar2(20)unique,sex varchar2(20)notnull,scorenumber(5,2));
插入單條數(shù)據(jù)
insertintostuvalues(1,'張三','男',86.5654);
插入多條數(shù)據(jù)
begin
insert into stu values(7,'張三3','男',86.5654);insertintostuvalues(8,'張三4','男',86.5654);insertintostuvalues(9,'張三5','男',86.5654);insertintostuvalues(10,'張三6','男',86.5654);
end;
MySQL中插入多條數(shù)據(jù)
insertintostuvalues(7,'張三3','男',86.5654),(8,'張三4','男',86.5654),(9,'張三5','男',86.5654),(10,'張三6','男',86.5654);
對比3:自增長的實現(xiàn)
Oracla中創(chuàng)建序列
create sequence stu_seq start with 1;
創(chuàng)建序列后插入數(shù)據(jù)
insert into stu values(stu_seq.nextval,'李四異','男',86.5654);
刪除序列
drop sequence stu_seq;
Oracle中添加約束
create table person1(pidnumberprimarykey,pname varchar2(20)unique,degree varchar2(20)default '科',jobtime datenot null,scorenumber(5,2),didnumber,foreign key(did)referencesdept1(did),check(score>=0andscore<=100));check(score>=0andscore<=100);
Oracle開發(fā)jdbc
1、添加jar包
ojbdc.jar
2、
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:orcl", "scott", "qq123");
/String sql = "delete from riaks3 where id=?";
pre = con.prepareStatement(sql);
pre.setInt(1, Integer.parseInt(id));
int a = pre.executeUpdate();