Hopes

          Start Here..

           

          ORACLE中添加刪除主鍵

          1、創建表的同時創建主鍵約束
          (1)無命名
          create table student (
           studentid int primary key not null,
           studentname varchar(8),
           age int);
          (2)有命名
          create table students (
             studentid int ,
             studentname varchar(8),
             age int,
             constraint yy primary key(studentid));
          2、刪除表中已有的主鍵約束
          (1)有命名
           alter table students drop constraint yy;
          (2)無命名
          可用 SELECT   *   from   user_cons_columns;
          查找表中主鍵名稱得student表中的主鍵名為SYS_C002715
          alter table student drop constraint SYS_C002715;
           
          3、向表中添加主鍵約束
           alter table student add constraint pk_student primary key(studentid); 

          posted on 2012-05-06 19:40 ** 閱讀(2756) 評論(2)  編輯  收藏

          評論

          # re: ORACLE中添加刪除主鍵 2013-11-25 16:18 五星村小黃

          3、向表中添加主鍵約束
          alter table student add constraint pk_student primary key(studentid);

          這個貌似不對哦,應該是
          alter table student add constraint pk_student_studentid primary key(studentid);

          煩請樓主幫忙再看看,謝謝先  回復  更多評論   

          # re: ORACLE中添加刪除主鍵 2013-11-25 17:02 五星村小黃

          不好意思 樓主 是我自己理解不對 在同一個系統下,約束名不能重復,不好意思,打擾了  回復  更多評論   


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          統計

          公告

          你好!

          常用鏈接

          留言簿(2)

          隨筆檔案

          文章分類

          文章檔案

          新聞檔案

          相冊

          收藏夾

          C#學習

          友情鏈接

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 长沙市| 新沂市| 赤城县| 舒城县| 安义县| 蓬莱市| 特克斯县| 巴林左旗| 类乌齐县| 南宫市| 湖州市| 邵阳市| 德昌县| 巴林左旗| 三亚市| 兴山县| 益阳市| 沛县| 兰西县| 榆树市| 和静县| 塔城市| 安顺市| 资溪县| 洪洞县| 沙湾县| 通海县| 南康市| 酒泉市| 靖安县| 聂荣县| 甘南县| 资兴市| 屏东市| 五原县| 长葛市| 黄冈市| 巴青县| 南川市| 兴仁县| 兴山县|