最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Oracle創(chuàng)建表語句詳解

 更新時間:2024年07月03日 10:51:56   作者:何以解憂,唯有..  
這篇文章主要介紹了Oracle創(chuàng)建表語句,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

一、前言

oracle 創(chuàng)建表時,表名稱會自動轉(zhuǎn)換成大寫,oracle 對表名稱的大小寫不敏感。

oracle 表命名規(guī)則:

  • 1、必須以字母開頭
  • 2、長度不能超過30個字符
  • 3、避免使用 Oracle 的關(guān)鍵字
  • 4、只能使用A-Z、a-z、0-9、_#S

二、語法

2.1 創(chuàng)建表 create table

-- 創(chuàng)建表: student_info 屬主: scott (默認(rèn)當(dāng)前用戶)

create table scott.student_info (
  sno         number(10) constraint pk_si_sno primary key,
  sname       varchar2(10),
  sex         varchar2(2),
  create_date date
);

-- 添加注釋
comment on table scott.student_info is '學(xué)生信息表';
comment on column scott.student_info.sno is '學(xué)號';
comment on column scott.student_info.sname is '姓名';
comment on column scott.student_info.sex is '性別';
comment on column scott.student_info.create_date is '創(chuàng)建日期';

-- 語句授權(quán),如:給 hr 用戶下列權(quán)限
grant select, insert, update, delete on scott.student_info to hr;

插入驗證數(shù)據(jù):

-- 插入數(shù)據(jù)
insert into scott.student_info (sno, sname, sex, create_date)
values (1, '張三', '男', sysdate);
insert into scott.student_info (sno, sname, sex, create_date)
values (2, '李四', '女', sysdate);
insert into scott.student_info (sno, sname, sex, create_date)
values (3, '王五', '男', sysdate);

-- 修改
update scott.student_info si
   set si.sex = '女'
 where si.sno = 3;
 
-- 刪除 
delete scott.student_info si where si.sno = 1; 

-- 提交
commit; 

-- 查詢
select * from scott.student_info;

2.2 修改表 alter table

1. '增加' 一列或者多列

alter table scott.student_info add address varchar2(50);
alter table scott.student_info add (id_type varchar2(2), id_no varchar2(10));

2. '修改' 一列或者多列

  • (1) 數(shù)據(jù)類型
alter table scott.student_info modify address varchar2(100);
alter table scott.student_info modify (id_type varchar(20), id_no varchar2(20));
  • (2) 列名
alter table scott.student_info rename column address to new_address;
  • (3) 表名
alter table scott.student_info rename to new_student_info ;
alter table scott.new_student_info rename to student_info;

3. '刪除' 一列或者多列,刪除多列時,不需要關(guān)鍵字 column

alter table scott.student_info drop column sex;
alter table scott.student_info drop (id_type, id_no);

2.3 刪除表 drop table

-- 刪除表結(jié)構(gòu)
drop table scott.student_info;

2.4 清空表 truncate table

-- 清空表數(shù)據(jù)
truncate table scott.student_info;

2.5 查詢表、列、備注信息

  • 權(quán)限從大到小:
'dba_xx' > all_xx > user_xx ('dba_xx' DBA 用戶才有權(quán)限)
  • 1. 查詢表信息
select * from dba_tables; -- all_tables、user_tables
  • 2. 查詢表的備注信息
select * from dba_tab_comments;
  • 3. 查詢列信息 
select * from dba_tab_cols t order by t.column_id;
  • 4. 查詢列的備注信息
select * from dba_col_comments;

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Orcale權(quán)限、角色查看創(chuàng)建方法

    Orcale權(quán)限、角色查看創(chuàng)建方法

    查看當(dāng)前用戶擁有的系統(tǒng)權(quán)限、創(chuàng)建用戶、授予擁有會話的權(quán)限、授予無空間限制的權(quán)限等等,感興趣的朋友可以參考下哈,希望對你有所幫助
    2013-05-05
  • Oracle SqlPlus設(shè)置Login.sql的技巧

    Oracle SqlPlus設(shè)置Login.sql的技巧

    sqlplus在啟動時會自動運行兩個腳本:glogin.sql、login.sql這兩個文件,接下來通過本文給大家介紹Oracle SqlPlus設(shè)置Login.sql的技巧,對oracle sqlplus設(shè)置相關(guān)知識感興趣的朋友一起學(xué)習(xí)吧
    2016-01-01
  • Oracle如何修改當(dāng)前的序列值實例詳解

    Oracle如何修改當(dāng)前的序列值實例詳解

    很多時候我們都會用到oracle序列,那么我們怎么修改序列的當(dāng)前值呢?下面這篇文章主要給大家介紹了關(guān)于Oracle如何修改當(dāng)前的序列值的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-05-05
  • 詳解Oracle dg 三種模式切換

    詳解Oracle dg 三種模式切換

    這篇文章主要介紹了詳解Oracle dg 三種模式切換 的相關(guān)資料,需要的朋友可以參考下
    2015-12-12
  • 淺談Oracle數(shù)據(jù)庫的建模與設(shè)計

    淺談Oracle數(shù)據(jù)庫的建模與設(shè)計

    淺談Oracle數(shù)據(jù)庫的建模與設(shè)計...
    2007-03-03
  • 使用PLSQL遠(yuǎn)程連接Oracle數(shù)據(jù)庫的方法(內(nèi)網(wǎng)穿透)

    使用PLSQL遠(yuǎn)程連接Oracle數(shù)據(jù)庫的方法(內(nèi)網(wǎng)穿透)

    Oracle數(shù)據(jù)庫來源于知名大廠甲骨文公司,是一款通用數(shù)據(jù)庫系統(tǒng),能提供完整的數(shù)據(jù)管理功能,而Oracle數(shù)據(jù)庫時關(guān)系數(shù)據(jù)庫的典型代表,其數(shù)據(jù)關(guān)系設(shè)計完備,這篇文章主要介紹了使用PLSQL遠(yuǎn)程連接Oracle數(shù)據(jù)庫的方法(內(nèi)網(wǎng)穿透),需要的朋友可以參考下
    2023-03-03
  • Oracle SQL中實現(xiàn)indexOf和lastIndexOf功能的思路及代碼

    Oracle SQL中實現(xiàn)indexOf和lastIndexOf功能的思路及代碼

    INSTR的第三個參數(shù)為1時,實現(xiàn)的是indexOf功能;為-1時實現(xiàn)的是lastIndexOf功能,具體實現(xiàn)如下,感興趣的朋友可以參考下哈下,希望對大家有所幫助
    2013-05-05
  • Oracle數(shù)據(jù)庫系統(tǒng)使用經(jīng)驗六則

    Oracle數(shù)據(jù)庫系統(tǒng)使用經(jīng)驗六則

    Oracle數(shù)據(jù)庫系統(tǒng)使用經(jīng)驗六則...
    2007-03-03
  • Oracle磁盤排序問題從定位到解決的完整實操指南

    Oracle磁盤排序問題從定位到解決的完整實操指南

    在Oracle數(shù)據(jù)庫運維中,磁盤排序是高頻出現(xiàn)的性能問題,不僅會占用大量臨時表空間,還會拖慢SQL執(zhí)行效率,甚至引發(fā)數(shù)據(jù)庫整體響應(yīng)遲緩,本文結(jié)合一線運維經(jīng)驗,梳理出發(fā)現(xiàn)問題,定位源頭,分析原因,優(yōu)化解決,長期預(yù)防的全流程排查方法,需要的朋友可以參考下
    2026-03-03
  • Oracle捕獲問題SQL解決CPU過渡消耗

    Oracle捕獲問題SQL解決CPU過渡消耗

    本文通過實際業(yè)務(wù)系統(tǒng)中調(diào)整的一個案例,試圖給出一個常見CPU消耗問題的一個診斷方法.
    2007-03-03

最新評論

宣恩县| 三明市| 双流县| 外汇| 盐城市| 盐亭县| 岐山县| 永丰县| 增城市| 利川市| 汪清县| 永济市| 大洼县| 旺苍县| 玉田县| 广宁县| 潞城市| 澄城县| 新余市| 元朗区| 内乡县| 新和县| 勃利县| 增城市| 西乡县| 永定县| 永川市| 佛学| 通州市| 深圳市| 同心县| 双城市| 揭东县| 乌恰县| 赤峰市| 富锦市| 湟中县| 二连浩特市| 平昌县| 三原县| 郯城县|