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

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

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

一、前言

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

oracle 表命名規(guī)則:

  • 1、必須以字母開頭
  • 2、長(zhǎng)度不能超過30個(gè)字符
  • 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é)號(hào)';
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;

插入驗(yàn)證數(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. '刪除' 一列或者多列,刪除多列時(shí),不需要關(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)限從大到?。?/li>
'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é)

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

相關(guān)文章

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

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

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

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

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

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

    很多時(shí)候我們都會(huì)用到oracle序列,那么我們?cè)趺葱薷男蛄械漠?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ù)庫(kù)的建模與設(shè)計(jì)

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

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

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

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

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

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

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

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

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

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

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

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

最新評(píng)論

邓州市| 永仁县| 元阳县| 宁国市| 三原县| 海淀区| SHOW| 伽师县| 灵石县| 六枝特区| 凤城市| 厦门市| 夏邑县| 平凉市| 温州市| 平乡县| 亳州市| 济源市| 常山县| 浦县| 浪卡子县| 云霄县| 榆林市| 苏州市| 焉耆| 桂东县| 会理县| 孝义市| 塔城市| 濮阳市| 平南县| 东城区| 高唐县| 新竹县| 阳江市| 安阳县| 江华| 迭部县| 余江县| 太仓市| 靖安县|