heima-Oracle学习-day1
生活随笔
收集整理的這篇文章主要介紹了
heima-Oracle学习-day1
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
play1
--創建表空間 create tablespace itheima datafile 'C:\app\Data\itheima.dbf' size 100m autoextend on next 10m;--刪除表空間 /*drop tablespace itheima;*/-- 創建用戶 create user itheima identified by itheima default tablespace itheima;--給用戶授權 --oracle 數據庫中常用角色 connect -- 連接角色,基本角色 resource --開發者角色 dba --超級管理員角色-- 給lewen 用戶授權dba角色 grant dba to itheima;--切換到lwen用戶下 -- c#lewen 登錄名 -- 創建一個person表create table person(pid number(20),pname varchar2(10) );--- 修改表結構 -- 添加一列alter table person add (gender number(1)); -- 存1或2-- 修改列類型 alter table person modify gender char(1);-- 修改列名稱 alter table person rename column gender to sex;-- 刪除一列 alter table person drop column sex;-- 查詢表中記錄 select * from person---- 添加一條記錄 insert into person (pid,pname) values (1,'小明'); -- 臟數據 -- 提交事務 commit;-- 修改一條記錄 update person set pname='小馬' where pid=1; commit;---- 三個刪除 -- 刪除表中全部記錄 delete from person; -- 刪除表結構 drop table person;-- 先刪除表,再創建表。效果等同于刪除表中全部記錄。 -- 在數據量大的情況下,尤其在表中帶有索引的情況下,該操作效率高。 -- 索引可以提供查詢效率,但是會影響增刪改效率。先刪除索引 truncate table person;---- 序列不真的屬于在何一張表,但是可以邏輯和表做綁定。 --—- 序列:默認從1開始,依次遞增,主要用來給主鍵賦值使用。 ----dual:虛表,只起為了補全語法,沒有在何意義。create sequence s_person; select s_person.nextval from dual; select s_person.currval from dual; -- 當前值---- 添加一條記錄 insert into person (pid,pname) values (s_person.nextval,'小明'); -- 臟數據 commit; -- 提交事務select * from person;----scott用戶,密碼tiger。 --- 需要解鎖 scott alter user scott account unlock; -- 解鎖密碼[此句也可以用來重置密碼] alter user scott identified by tiger;總結
以上是生活随笔為你收集整理的heima-Oracle学习-day1的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 03 | SRE切入点:选择SLI,设定
- 下一篇: heima Oracle day2