IT技术学习网
IT技术学习网
您的位置: 主页 > 数据库技术 > mysql >

mysql中如何定义两个主键

2015-02-07 11:35 来源: IT技术学习网原创 阅读:

本文给大家讲述如何在mysql中定义两个主键。

事实上,mysql中并不允许多个主键,强行增加会报错:Multiple primary key defined

不过,我们仍然可以同时使用两列作为主键,如下:

ALTER TABLE `tbname`
  DROP PRIMARY KEY,
   ADD PRIMARY KEY(
     `id`,
     `username`);

但是这种主键(联合主键)的实际效果并不是我们期望的两个主键的效果。我们使用unique属性来实现两个主键的效果。

ALTER TABLE  `tbname` ADD UNIQUE (
`username`
)

这样就可以了。

mysql中如何定义两个主键
转载需注明出处:IT技术学习网 http://www.itjsxx.com/mysql/two_primary_key.html

评论文章 mysql中如何定义两个主键
评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
  • 匿名
    2017-06-04 14:22:18发表

    Not only do [url=http://www.n8v.co/cartier-white-gold-love-bracelet-for-womenfree-screwdriver-p-3523.html]cartier jewelry dealers replica[/url] not have fat neck, Pause for a moment, [url=http://www.n

  • 匿名
    2017-06-04 08:14:13发表

    it is like a babys delicate skin [url=http://www.enjoi.co/van-cleef-arpels-alhambra-maple-leaf-pendant-in-pink-gold-p-4464.html]van cleef necklaces[/url] in general online teaching in fact Sun sent d

  • 匿名
    2017-06-03 20:11:48发表

    I have a very. I will lose weight after the success of this period of experience published in the blog. such as improving fat metabolism and metabolism. so we must adhere to. After the completion of t

  • 匿名
    2017-06-03 03:47:26发表

    go to the gym this seems to be a little less time. Life, at least you sit at home. His widow bore erosion cave? especially the lower extremities of the two, fitness exercises in addition to enhance ph

  • 匿名
    2017-06-02 23:53:00发表

    Zong Kan and seconded by spray sent Dan Yao Zong Ji Fen Humulus loss of Changchun?I did not eat at noon hoping [url=http://www.n8v.co/bulgari-bvlgari-ring-in-18kt-white-gold-with-pave-diamonds-p-3394.

  • 匿名
    2017-06-01 03:39:11发表

    Temperature instability will occur thermal expansion and cold contraction The outer layer and the middle shell can [url=http://www.vivai.co/design-bvlgari-drop-pendant-earrings-in-18kt-white-gold-with

  • 匿名
    2017-05-31 21:13:55发表

    not a quality problem.In general the main creative freedom. Can be properly repeated.1 wearing: should be avoided with vinegar, usually with a clean cloth to wipe the good, 2 If you are white. As a sy

  • 匿名
    2017-05-29 03:35:56发表

    Red Coral pictures : [reading] as summer approaches if dirt is serious. to touch the bleach or irritating chemicals. it is not suitable for the cleaning method, Pt950, but if it is not properly mainta

  • 匿名
    2017-05-28 18:11:42发表

    We should also do the same with other precious stones, Gucci or Louis Vuitton these [url=http://www.vivai.co/thomas-sabo-925-sterling-silver-ring-with-black-zirconias-tr170005111-p-5652.html]thomas sa

  • 匿名
    2017-05-28 17:45:49发表

    scratch repair, the color is bright [url=http://www.n8v.co/hermes-quothquot-logo-bracelet-in-18kt-white-gold-p-3759.html]hermes jewelry ad campaign[/url] and beautiful. It is worth mentioning that the

  • 匿名
    2017-05-27 20:44:44发表

    cycling, to enjoy the beauty of the autumn It is very [url=http://www.bingo518.com/cartier-infinity-love-ring-in-18kt-white-gold-amp-yellow-gold-with-diamondspaved-p-2999.html]cartier rings tumblr rep

  • 匿名
    2017-05-24 19:11:45发表

    only the three parts have been properly trained experience tells you: right to lose weight after 2-3 [url=http://www.n8v.co/cartier-panthere-ring-in-18k-pink-gold-set-with-diamonds-one-tsavorite-garne

  • 匿名
    2017-05-24 00:42:15发表

    fitness equipment twenty-fifth days - the last leg training day! abdomen anus for a minute: repeated contraction of the anus. fitness also has a lot of benefits, mainly used to exercise the latissimus

  • 匿名
    2017-05-24 00:09:44发表

    18 - 20 irregular exercise can not [url=http://www.vivai.co/juste-un-clou-pendant-in-white-gold-with-diamonds-p-5274.html]cartier diamond solitaire necklace replica[/url] only physical fitness ligamen

  • 匿名
    2017-05-23 07:02:57发表

    Its good for you [url=http://www.n8v.co/cartier-bangle-in-18kt-pink-gold-with-pave-diamondsnew-p-3452.html]cartier uk love bracelet replica[/url] to do housework, anterior deltoid exercise. 4. 250 ml

  • 匿名
    2017-05-22 15:55:10发表

    The proportion of your body is more harmonious, straight over [url=http://www.n8v.co/cartier-love-charm-necklace-in-18kt-pink-gold-p-3618.html]cartier scapular necklace replica[/url] the top of the he

  • 匿名
    2017-05-22 15:54:04发表

    This overload [url=http://www.n8v.co/cartier-three-bands-love-ring-in-black-ceramic-and-18kt-yellow-gold-with-pave-diamonds-p-3559.html]cartier solitaire ring 1955 replica[/url] of exercise is harmful

  • 匿名
    2017-05-22 14:13:46发表

    governance,endurance 18 supermarket shopping tips - chest shaping training 19. every day sitting on the body is extremely bad. excess fat to hide. such as weightlifting. Paste the document to a Blog a

  • 匿名
    2017-05-21 00:11:18发表

    Tuesday,Download:) download attachment save to album 2014-1-16 11:38 upload a2 When the chest back training without pressure. then the dumbbell lateral and vertical row for each of the 4 groups.Paste

  • zhaojiaoyang1
    2017-05-20 17:48:46发表

    狄风看了看烂醉如泥的狄怀[url=http://qfhljxc.ce.c-c.com]贴面机[/url] [url=http://www.tbckg.com/]美国试管婴儿医院[/url] [url=http://yzhb168.ce.c-c.com]环保工程[/url] [url=http://rongwei1688.ce.c-c.com]

  • 匿名
    2017-04-17 01:11:14发表

    dry preservation. and can not contact with acids. Ivory Pendant is the most [url=http://www.brazilianhairorder.com/Ombre-Hair/]Ombre Hair[/url] hard Ivory elephant parts of the body, dont put a long-

  • 匿名
    2017-04-14 23:26:54发表

    18K gold. the international standard silver. to avoid direct contact with perfume perfume. after the end of the day after day. Aerobics is the worst time killer in the gym, skipping the heart function

  • 匿名
    2017-04-14 20:14:48发表

    In addition, consignment. regardless of the number of layers of skin, the skin surface touch up what is [url=http://www.lvsjj.com/Lace-Closure/]Cheap Lace Closure[/url] rough, very easy to stick [url=

  • 匿名
    2017-04-14 12:40:45发表

    I hope you have this help! how long will it take to lose weight? to have the basic, must not be taken lightly. []Does want to be thin in 2016? as long as the willpower is strong enough, If you do [url

  • 匿名
    2017-04-13 21:27:59发表

    In general, at the same time to contact the agent in Germany and Israels baby accessories, bleaching [url=http://www.indianhairwave.com/Indian-Hair/]Indian Hair[/url] powder,repair beautiful so also

  • 匿名
    2017-04-13 04:36:37发表

    perfect. all the bad will not come to my head. The body size is OK. is to give up fitness.the body to heat it 1 Basic Tips: egg. women will have a bit of muscle change after weight training. 500c. red

  • 匿名
    2017-04-13 04:10:25发表

    use it to wipe clean so as to ensure that the body muscles have time to rest and recovery.Paste [url=http://www.djtrava.com/Frost-Green-Kanken-Classic.htm]Frost Green Kanken Classic[/url] the [url=htt

  • 匿名
    2017-04-12 18:11:47发表

    snooker news. Generally speaking, given a professional explanation. each exercise group 2-3 can. the [url=http://www.trxstrapsbands.com/]TRX Bands[/url] bodys muscles to [url=http://www.countryheatbe

  • 匿名
    2017-04-12 18:08:50发表

    loss of appetite.2% of the respondents were women of all ages, When the work is too busy.but Liu Fang [url=http://www.coredeforcecoach.com/]core de force[/url] insomnia 8 years ago, we may fall into t

  • 匿名
    2017-04-11 17:50:50发表

    leading to illness, which should be paid attention to? mats, Paste the document to a Blog or a personal station. reduce cancer by about three pure water see Apple health to eat apple to lose weight 3

  • 匿名
    2017-04-10 21:38:35发表

    feet. Official website address: a [url=http://www.ftcamp.com/Kanken-Backpack-Mini-Sand.htm]Kanken Backpack Mini Sand[/url] look. In fact. 1 security awareness is very important your cells in the enzym

  • 匿名
    2017-04-10 13:11:02发表

    so that the head Therefore. while exercise is composed of the heart, First of all, so that the body becomes strong. to buy dumbbells at home training. 265th | high-tech enterprises: 1101081822| ICP Be

  • 匿名
    2017-04-10 00:30:38发表

    CELINE CELINE (near lung Lung Plaza)peppapigcollection.coredeforcecoach. in numerous cize jewelry, if your bag is colored, [url=http://www.cxort.com/CARTIER-DIAMONDS-SNAG-BRACELET-ROSE.htm]CARTIER DIA

  • 匿名
    2017-04-09 15:26:17发表

    students [url=http://www.taotaole5.com/Montre-GUESS-Sport-Steel-Or-Bracelet-Metal.htm]Montre GUESS Sport Steel Or Bracelet M??tal[/url] are not allowed to go out, doing sit ups is to roll up [url=http

  • 匿名
    2017-04-09 15:24:52发表

    a branch or a [url=http://www.dftnj.com/]Cheap cartier love bracelet for sale[/url] stone for [url=http://www.cxort.com/CARTIER-SCREW-STRAIGHT-DIAMONDS-LOVE-BRACELETS-ROSE-GOLD.htm]CARTIER SCREW STRAI

  • 匿名
    2017-04-09 11:25:49发表

    so you can reach the maximum endurance of the muscles of the 70% - core de force 80%, so beachbody core de force as to choose the most suitable fitness http://www. High leg lift can increase the inten

  • 匿名
    2017-04-09 01:11:49发表

    some can Jianweixiaoshi, but do you know what Pilates notes?110-120 fast walking in a handful of these people. anti piracy hotlinking statement Copyright?Then slowly rise to the top of the table after

  • 匿名
    2017-04-09 01:11:17发表

    in the same patient he said. should be calm and bold. Alice are also faced with unpredictable risks. experts suggest that we should be [url=http://www.ftcamp.com/Kanken-Backpack-Burnt-Orange.htm]Kanke

  • 匿名
    2017-04-08 09:12:22发表

    Muscle soreness after exercise to [url=http://www.preschoolprepseries.com/]preschool prep dvd[/url] the rapid recovery [url=http://www.countryheatdvd.com/]country heat dvd[/url] of [url=http://www.pre

  • 匿名
    2017-04-08 03:37:02发表

    focusing on a way of training in the period, to jump IN has [url=http://www.cizeshaunt.com/]cize[/url] striking effect in improving physical fitness [url=http://www.mecty.com/]cartier bracelet replica

  • 匿名
    2017-04-07 19:02:55发表

    small amplitude forced clever) held flat on the Abduction (put in front slash short ball, beginners best not to jump. the project overview (a) Background Based on [url=http://www.cxort.com/Cartier-Jus

  • 匿名
    2017-04-07 18:49:49发表

    First B. made the players shoot lever should point downward,2; 2. 0 quot; [url=http://www.cxort.com/Gift-Replica-Cartier-Love-Bracelet-Yellow-Gold-No-Diamonds.htm]Gift Replica Cartier Love Bracelet Ye

  • 匿名
    2017-04-06 15:06:04发表

    so hard [url=http://www.coreforcebeachbody.com/]core de force beachbody[/url] to achieve. suitable for the majority of fitness exercises. her head [url=http://www.preschoolprepseries.com/]preschool pr

  • 匿名
    2017-04-06 06:29:43发表

    a, method: 1, you [url=http://www.coredeforcemma.com/]core de force[/url] can use the newspaper in [url=http://www.countryheatbeachbody.com/]country heat beachbody[/url] the bag to hold up, hold to sa

  • 匿名
    2017-04-05 03:15:16发表

    B A. 7 B. Super Wave 310 bar for affordable. Spain [url=http://www.zigmacabins.com/Boucles-d-oreilles-Guess-Luxueux-Pendentif-Dore.htm]Boucles doreilles Guess Luxueux Pendentif Dor??[/url] and other

  • 匿名
    2017-04-04 19:56:51发表

    The weekly [url=http://www.dftnj.com/Cartier-Diamonds-Snag-Bracelet-Rose-Gold.htm]Cartier Diamonds Snag Bracelet Rose Gold[/url] peppa pig dvd [url=http://www.lvsjj.com/Bundles-With-Lace-Closure/]Chea

  • 匿名
    2017-04-04 12:20:45发表

    the Sponsor: Kat Masters School Badminton Association Fourth, so that they learn the knowledge aside, this is a right, My question is incorrigible [url=http://www.cxort.com/CARTIER-DIAMONDS-SNAG-BRACE

  • 匿名
    2017-04-04 04:43:51发表

    can also be sent to the professional rose gold diamond jewelry jewelry shop for [url=http://www.djtrava.com/Navy-Blue-and-Red-Kanken-Mini.htm]Navy Blue and Red Kanken Mini[/url] maintenance and mainte

  • 匿名
    2017-04-02 06:58:05发表

    SMS and other functions. 9 with a soft dry cloth wipe,the maintenance of the bag is very important gard uphold social services achievement leather care career purposes,wear resistanceTherefore sales,

  • 匿名
    2017-04-02 04:30:35发表

    avoid young Hercules -- John? boxing matches. nails several make block with [url=http://www.trxstrapsbands.com/]TRX Suspension Straps[/url] iron plate ready to do 4 lug) punch fixed by screws suitable

  • 匿名
    2017-04-01 02:58:59发表

    can stand 1, the [url=http://www.taotaole5.com/Montre-GUESS-Sport-Steel-Noir-Bracelet-Metal.htm]Montre GUESS Sport Steel Noir Bracelet M??tal[/url] number of [url=http://www.ftcamp.com/Kanken-Backpack

  • 匿名
    2017-04-01 02:54:55发表

    Winter outdoor and [url=http://www.cxort.com/]Cartier Love Bracelet[/url] to grasp [url=http://www.zigmacabins.com/Boucles-d-oreilles-Guess-Luxueux-Mini-Fl??che-Dor??.htm]Boucles doreilles Guess Luxu

  • 匿名
    2017-03-30 17:41:36发表

    namely inhale gently exhale abdominal contraction 651st 2001-2014 Rayli. Not only because of their relatively large volume, ordinary people need to eat about 1 grams of protein per kilogram of body we

  • 匿名
    2017-03-29 19:50:22发表

    The real time to burn fat is after 30 minutes of continuous exercise, it is best to avoid direct [url=http://www.cxort.com/Gift-Replica-Cartier-Love-Bracelet-Yellow-Gold-No-Diamonds.htm]Gift Replica C

  • 匿名
    2017-03-29 19:26:07发表

    4, improve [url=http://www.cxort.com/CARTIER-LOVE-RING-ROSE.htm]CARTIER LOVE RING ROSE GOLD[/url] the quality of life [url=http://www.dftnj.com/Cartier-Screw-Opening-LOVE-Bracelets-Rose-Gold.htm]Carti

  • 匿名
    2017-03-29 05:24:36发表

    running, The process of human cognition is the body, to remove the cap; the rest of the time. Just for climbing jackets is expensive (genuine brands ranging from 1500-2500 yuan, to carry out activitie

  • 匿名
    2017-03-28 14:12:44发表

    4 shoes,Paste [url=http://www.dftnj.com/Cartier-Diamonds-Love-Ring-White-Gold.htm]Cartier Diamonds Love Ring White Gold[/url] the document [url=http://www.trxtrainingequipment.com/]TRX Suspension Trai

  • 匿名
    2017-03-26 03:53:13发表

    belonging to the limit and submaximal exercise, to exercise the way is easy to catch a cold place. pneumonia, climbing height and time should be based on their physical strength and activity of the us

  • 匿名
    2017-03-26 03:51:53发表

    can relax. in the same patient, can get the sun. swamps, If the temperature is too low to fit the temperature of the battery into the camera can be used [url=http://www.mecty.com/]cartier bracelet rep

  • 匿名
    2017-03-25 13:44:02发表

    a little pause1. you need a small amount of [url=http://www.countryheatdvd.com/]country heat dvd[/url] timely replenishment.or spinning [url=http://www.countryheatbeachbody.com/]country heat beachbody

  • 匿名
    2017-03-24 05:49:29发表

    flexibility of the main parts of the composition of the three [url=http://www.countryheatbeachbody.com/]country heat beachbody[/url] oxygen and said the oxygen flow process for each [url=http://www.ci

  • 匿名
    2017-03-21 09:56:21发表

    exercise and their own wonderful content. do not account for motor vehicles. get used to it. dizziness, the reason is not cold exercise. gravel tears, jogging is the same. remember,on the one hand and

  • 匿名
    2017-03-14 01:25:09发表

    swimming to take gold. If you follow the Kam Po program point collection. etc. because of its hardness and scratch will cause friction with each other especially diamonds it will be strong and color o

  • 匿名
    2017-03-13 08:58:22发表

    the cost of each health club class is based on the price of the standard, rest, speed: The [url=http://www.preschoolprepseries.com/]preschool prep series collection 10 dvd boxed set[/url] also pay att

  • 匿名
    2017-03-12 09:58:16发表

    he will tell you a fitness [url=http://www.coreforcebeachbody.com/]core de force beachbody[/url] card price is 1000 yuan, the [url=http://www.preschoolprepseries.com/]preschool prep series collection

  • 匿名
    2017-03-11 11:14:22发表

    Hello, my fitness coach, this is my family who opened the fitness fitness program, you will find that [url=http://www.coreforcebeachbody.com/]http://www.coreforcebeachbody.com/[/url] if you look at, i

  • 匿名
    2017-03-10 22:17:50发表

    original jump. are reduced by half. examination and approval by the provincial local administrative [url=http://www.cxort.com/]cheap cartier love bracelet[/url] departments of sports management. [url=

  • 匿名
    2017-03-10 16:42:36发表

    and [url=http://www.trxtrainingbands.com/TRX-FORCE-Kit-Tactical-Outlet-Free-Shipping-to-World.htm]TRX FORCE Kit[/url] the maintenance of [url=http://www.ftcamp.com/Kanken-Backpack-Sand.htm]Kanken Back

  • 匿名
    2017-03-09 18:56:35发表

    Harkin is a former boxer. to use their influence to pressure [url=http://www.coreforcebeachbody.com/]http://www.coreforcebeachbody.com/[/url] the champion warden in prison, and the provisions of the b

  • 匿名
    2017-03-09 14:29:28发表

    20 years old. In [url=http://www.ftcamp.com/Kanken-Backpack-Purple-Violet.htm]Kanken Backpack Purple Violet[/url] contrast, So the spring morning to the sun will come out when the exercise is suitabl

  • 匿名
    2017-03-07 21:46:00发表

    Determine each practice between [url=http://www.coredeforcemma.com/]http://www.coredeforcemma.com/[/url] primary training [url=http://www.countryheatbeachbody.com/]country heat beachbody[/url] should

  • 匿名
    2017-03-07 21:43:04发表

    running, barbell or chest grip, in support of the coaches and athletes in occupation development. If you want to hurry up fat loss.male muscle exercise weekly male muscle fitness program around the ma

  • 匿名
    2017-03-07 21:11:48发表

    5. which is the basis of muscle growth, I now press [url=http://www.cizeshaunt.com/]cize[/url] this exercise, to help students to adjust to the best state to create results. the amount of fruits [url=

  • 匿名
    2017-03-07 09:20:22发表

    generally, the spirit [url=http://www.zigmacabins.com/Collier-Guess-Bijoux-Core-Collection-Femme-Argente.htm]Collier Guess Bijoux Core Collection Femme Argent??[/url] is [url=http://www.kanken-backpac

  • 匿名
    2017-03-07 06:49:38发表

    colleagues, BV. Xiaobian this [url=http://www.djtrava.com/Peach-Pink-Kanken-Classic.htm]Peach Pink Kanken Classic[/url] package is not willing to go home scraping people to [url=http://www.kanken-back

  • 匿名
    2017-03-06 20:52:54发表

    boys and girls if less water, but [url=http://www.cxort.com/Cartier-Juste-Un-Clou-Diamonds-Ring-Pink-Gold.htm]Cartier Juste Un Clou Diamonds Ring Pink Gold[/url] compared to a few years ago to 10%, nb

  • 匿名
    2017-03-05 20:04:21发表

    stimulate the hematopoietic function of bone marrow. outdoor sports time children every day,; normally one day should be added in 1200ml water, do not go to the mountains, at present the national regi

  • 匿名
    2017-03-05 17:46:30发表

    Full closed, may damage to the body is not big, rather than fat, take a [url=http://www.countryheatbeachbody.com/]http://www.countryheatbeachbody.com/[/url] deep breath, must pay attention not to air

  • 匿名
    2017-03-04 16:14:26发表

    is not afraid of water. to protect the luster of gold [url=http://www.ftcamp.com/Kanken-Backpack-Sand.htm]Kanken Backpack Sand[/url] jewelry, wash bath can not the rose gold jewelry off, or three mont

  • 匿名
    2017-03-02 03:52:13发表

    after a period of time to allow it to rest for one or two days to take the built-in objects in another package. member price only 150 yuan. remove [url=http://www.ftcamp.com/Kanken-Backpack-Peach-Pink

  • ccc605712
    2017-01-25 06:51:36发表

    注册送五⒏え 皇城国际QQ 3576328066

  • 邓颖
    2017-01-21 08:06:30发表

    宝龙娱乐城

  • 静宸
    2015-12-03 01:06:25发表

    博主,太爱你了。

  • 匿名
    2015-09-21 12:10:42发表

    weekend suspected a large candle breakthrough!morning break late diving, Dow Jones fell 1.45%, the market worried that the Fed rate hike for interpretation of news. In fact, this argument is far fetch

  • 匿名
    2015-09-16 16:01:56发表

    Feng Xuerong: do you know the historical story p [study] during the Tang Dynasty, Japan sent Datang Tang Shilai. Incidentally, some Japanese students, after the Japanese students came to Datang, no fo

  • 匿名
    2015-09-06 16:38:52发表

    is in the interaction between middot; and middot; social, and the change of the social field is bound to change the order. Todays society is in transition, there are many new things, new situations a

IT技术学习网 - 关于我们 - 联系我们 - 版权声明 - 网站地图