Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Add primary Key as GUID automatic generation

Add primary Key as GUID automatic generation

Scheduled Pinned Locked Moved Database
tutorialdatabaseoracletoolsannouncement
13 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

    create table [table] (
    id raw(32) default sys_guid(),
    ...,
    constraint pk_id primary key (id)
    );

    I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)

    M Offline
    M Offline
    MrKBA
    wrote on last edited by
    #3

    Thank you for that. But what about Access database ?

    Kornfeld Eliyahu PeterK E 2 Replies Last reply
    0
    • M MrKBA

      Thank you for that. But what about Access database ?

      Kornfeld Eliyahu PeterK Offline
      Kornfeld Eliyahu PeterK Offline
      Kornfeld Eliyahu Peter
      wrote on last edited by
      #4

      I don't know him!

      I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)

      "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

      M 1 Reply Last reply
      0
      • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

        I don't know him!

        I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)

        M Offline
        M Offline
        MrKBA
        wrote on last edited by
        #5

        I talk about Microsoft Office access

        Kornfeld Eliyahu PeterK 1 Reply Last reply
        0
        • M MrKBA

          I talk about Microsoft Office access

          Kornfeld Eliyahu PeterK Offline
          Kornfeld Eliyahu PeterK Offline
          Kornfeld Eliyahu Peter
          wrote on last edited by
          #6

          Please do not use rude words here...

          I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)

          "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

          M 1 Reply Last reply
          0
          • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

            Please do not use rude words here...

            I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)

            M Offline
            M Offline
            MrKBA
            wrote on last edited by
            #7

            sorry if I did a mistake

            Kornfeld Eliyahu PeterK 1 Reply Last reply
            0
            • M MrKBA

              sorry if I did a mistake

              Kornfeld Eliyahu PeterK Offline
              Kornfeld Eliyahu PeterK Offline
              Kornfeld Eliyahu Peter
              wrote on last edited by
              #8

              The only mistake you did that you didn't realized the joke icon :laugh:

              I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)

              "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

              1 Reply Last reply
              0
              • M MrKBA

                Thank you for that. But what about Access database ?

                E Offline
                E Offline
                Estys
                wrote on last edited by
                #9

                For ms access the best approximation is

                id_memberships AUTOINCREMENT PRIMARY KEY

                Cheers

                M 1 Reply Last reply
                0
                • M MrKBA

                  I have Some table in database (Access, SQLServer and Oracle) haven' t Primary Key.Client need to do a replication for this database. I ask how do the update script for one table to add primary key as GUID automatic (it means when I add a record as before there is no need to edit source code) I did this for SQLServer and it works but for Access and Oracle no idea how to do this :( example :

                  create table [SAC_MEMBERSHIPS](
                  id_group nvarchar(40) FOREIGN KEY REFERENCES SAC_SUBJECTS(id_subject),
                  id_user nvarchar(40) FOREIGN KEY REFERENCES SAC_SUBJECTS(id_subject),
                  id_memberships UNIQUEIDENTIFIER NOT NULL DEFAULT NEWSEQUENTIALID() PRIMARY KEY
                  )/

                  ALTER TABLE [SAC_MEMBERSHIPS]
                  ADD [id_memberships] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWSEQUENTIALID() PRIMARY KEY
                  ON [PRIMARY]

                  /

                  J Offline
                  J Offline
                  jschell
                  wrote on last edited by
                  #10

                  What are you going to do if the record is updated rather than added?

                  1 Reply Last reply
                  0
                  • M MrKBA

                    I have Some table in database (Access, SQLServer and Oracle) haven' t Primary Key.Client need to do a replication for this database. I ask how do the update script for one table to add primary key as GUID automatic (it means when I add a record as before there is no need to edit source code) I did this for SQLServer and it works but for Access and Oracle no idea how to do this :( example :

                    create table [SAC_MEMBERSHIPS](
                    id_group nvarchar(40) FOREIGN KEY REFERENCES SAC_SUBJECTS(id_subject),
                    id_user nvarchar(40) FOREIGN KEY REFERENCES SAC_SUBJECTS(id_subject),
                    id_memberships UNIQUEIDENTIFIER NOT NULL DEFAULT NEWSEQUENTIALID() PRIMARY KEY
                    )/

                    ALTER TABLE [SAC_MEMBERSHIPS]
                    ADD [id_memberships] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWSEQUENTIALID() PRIMARY KEY
                    ON [PRIMARY]

                    /

                    B Offline
                    B Offline
                    Bernhard Hiller
                    wrote on last edited by
                    #11

                    Also Access has a Guid datatype.

                    CREATE TABLE [SAC_MEMBERSHIPS]
                    (
                    [id_memberships] GUID NOT NULL PRIMARY KEY,
                    ...

                    M 1 Reply Last reply
                    0
                    • E Estys

                      For ms access the best approximation is

                      id_memberships AUTOINCREMENT PRIMARY KEY

                      Cheers

                      M Offline
                      M Offline
                      MrKBA
                      wrote on last edited by
                      #12

                      Thank you , But I need it to be in automatic GUID forme.

                      1 Reply Last reply
                      0
                      • B Bernhard Hiller

                        Also Access has a Guid datatype.

                        CREATE TABLE [SAC_MEMBERSHIPS]
                        (
                        [id_memberships] GUID NOT NULL PRIMARY KEY,
                        ...

                        M Offline
                        M Offline
                        MrKBA
                        wrote on last edited by
                        #13

                        I use

                        id_memberships GUID PRIMARY KEY DEFAULT GenGUID() NOT NULL

                        But I can do in Update Request SQL :( Have you an idea how do the Update ?

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups