Hopes

          Start Here..

           

          ORACLE中添加刪除主鍵

          1、創(chuàng)建表的同時創(chuàng)建主鍵約束
          (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 ** 閱讀(2755) 評論(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 五星村小黃

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


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


          網(wǎng)站導航:
           

          導航

          統(tǒng)計

          公告

          你好!

          常用鏈接

          留言簿(2)

          隨筆檔案

          文章分類

          文章檔案

          新聞檔案

          相冊

          收藏夾

          C#學習

          友情鏈接

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 梁山县| 鹤山市| 邻水| 墨竹工卡县| 广宁县| 含山县| 武宣县| 敖汉旗| 卫辉市| 苍梧县| 吕梁市| 岳西县| 汉川市| 海南省| 修武县| 宝山区| 瓦房店市| 临汾市| 北宁市| 河曲县| 旬阳县| 丹棱县| 吉首市| 仙游县| 滦平县| 越西县| 嘉定区| 峨眉山市| 芜湖市| 改则县| 建阳市| 小金县| 兴隆县| 遂川县| 九龙坡区| 屏边| 南昌市| 唐河县| 保靖县| 江孜县| 黄龙县|