Professional Web Applications Themes

query to find primary key - MySQL

Hi, I have a question on primary keys. Just wanted to know how one can query a table to know what it's PK is? Thanks Ros...

  1. #1

    Default query to find primary key

    Hi,

    I have a question on primary keys. Just wanted to know how one can
    query a table to know what it's PK is?

    Thanks
    Ros

    roohbir Guest

  2. #2

    Default Re: query to find primary key

    On Mar 20, 1:01 pm, "roohbir" <com> wrote: 

    describe mytable

    strawberry Guest

  3. #3

    Default Re: query to find primary key

    > I have a question on primary keys. Just wanted to know how one can 

    SHOW INDEXES FROM <table name>;

    --
    Willem Bogaerts

    Application smith
    Kratz B.V.
    http://www.kratz.nl/
    Willem Guest

  4. #4

    Default Re: query to find primary key

    On Mar 20, 6:49 am, "strawberry" <com> wrote: 


    >
    > describe mytable[/ref]

    the table is

    DROP TABLE IF EXISTS `my_address_book`.`address`;
    CREATE TABLE `my_address_book`.`address` (
    `AddressId` int(10) unsigned NOT NULL auto_increment,
    `ContactId` int(10) unsigned NOT NULL,
    `AddTypeId` int(10) unsigned NOT NULL,
    `SuiteNo` int(10) unsigned NOT NULL,
    `StreetName` varchar(45) NOT NULL,
    `City` varchar(45) NOT NULL,
    `State` varchar(45) NOT NULL,
    `Country` varchar(45) NOT NULL,
    `PinCode` varchar(45) NOT NULL,
    PRIMARY KEY (`AddressId`),
    KEY `AddTypeId` (`AddTypeId`),
    KEY `ContactId` (`ContactId`),
    CONSTRAINT `address_ibfk_1` FOREIGN KEY (`ContactId`) REFERENCES
    `contact` (`ContactId`),
    CONSTRAINT `AddTypeId` FOREIGN KEY (`AddTypeId`) REFERENCES
    `address_type` (`AddTypeId`) ON DELETE CASCADE ON UPDATE CASCADE
    ) ENGINE=InnoDB DEFAULT CHT=latin1;

    roohbir Guest

  5. #5

    Default Re: query to find primary key

    On Mar 20, 9:32 pm, "roohbir" <com> wrote: 
    > [/ref]
    > [/ref]
    > [/ref]

    >
    > the table is
    >
    > DROP TABLE IF EXISTS `my_address_book`.`address`;
    > CREATE TABLE `my_address_book`.`address` (
    > `AddressId` int(10) unsigned NOT NULL auto_increment,
    > `ContactId` int(10) unsigned NOT NULL,
    > `AddTypeId` int(10) unsigned NOT NULL,
    > `SuiteNo` int(10) unsigned NOT NULL,
    > `StreetName` varchar(45) NOT NULL,
    > `City` varchar(45) NOT NULL,
    > `State` varchar(45) NOT NULL,
    > `Country` varchar(45) NOT NULL,
    > `PinCode` varchar(45) NOT NULL,
    > PRIMARY KEY (`AddressId`),
    > KEY `AddTypeId` (`AddTypeId`),
    > KEY `ContactId` (`ContactId`),
    > CONSTRAINT `address_ibfk_1` FOREIGN KEY (`ContactId`) REFERENCES
    > `contact` (`ContactId`),
    > CONSTRAINT `AddTypeId` FOREIGN KEY (`AddTypeId`) REFERENCES
    > `address_type` (`AddTypeId`) ON DELETE CASCADE ON UPDATE CASCADE
    > ) ENGINE=InnoDB DEFAULT CHT=latin1;[/ref]

    ha, i asked for that didn't I ;-)

    strawberry Guest

Similar Threads

  1. Primary Scratch & Windows Primary Paging file?
    By Tommy Oberst in forum Adobe Photoshop 7, CS, CS2 & CS3
    Replies: 14
    Last Post: April 15th, 10:26 PM
  2. Where to find: Advanced Query Wizard
    By zientar in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 1
    Last Post: February 6th, 03:55 PM
  3. Query to find today's records?
    By Glennzig in forum Coldfusion Database Access
    Replies: 6
    Last Post: January 10th, 08:01 PM
  4. Replies: 2
    Last Post: February 17th, 01:17 AM
  5. Convert a query to a list, or find an item in a query
    By Laverda668 in forum Macromedia ColdFusion
    Replies: 2
    Last Post: April 7th, 07:41 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139