oracle建表並設定ID為自動成長____oracle

來源:互聯網
上載者:User

CREATE TABLESPACE shoppingDATAFILE 'D:\oracle\mypc\oradata\orcl\shopping.dbf' SIZE 20M AUTOEXTEND ON ;create user shopping --建立 使用者 使用者名稱identified by shopping --密碼 密碼字元default tablespace shopping --預設資料表空間 資料表空間名temporary tablespace shopping; --暫存資料表空間 資料表空間名-- 賦予許可權grant connect to shopping with admin option;-- 角色grant DBA to shopping with admin option;

使用sql plus登陸系統管理員帳戶,給shopping使用者授DBA許可權

grant dba to shopping;

以下為設定ID自動成長步驟:

1、建表

2、建序列

3、建觸發器

插入自動成長ID

INSERT INTO TABLE_NAME(ID)
VALUES(bill_SEQ_ID.NEXTVAL);

 

注意點:後來我又遇到個問題,因為我的那個表中有欄位資料是空,實際表欄位設計的是不可為空白,我是用insert請句插入的資料“NULL”,所以在插入自動成長ID的時候報錯:

修改表欄位勾選 可為空白,除非ID外,其它欄位都可為空白,如果不為空白,那麼欄位資料裡面要確實不是NULL才可以

轉自:https://www.cnblogs.com/sincoolvip/p/5910751.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.