<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix"><br>
You can also (in mysql) tag a column as "unique":<br>
<br>
alter table blah add unique(column_name);<br>
<br>
This doesn't add a key AFAIK unless you ask it to be a key:<br>
<br>
alter table blah add unique key(column_name);<br>
<br>
If you will never refer to a row using the auto-increment column,
why have it?<br>
<br>
No problem having a table with no keys whatsoever, if you never
plan to pull up records without dumping the whole table. But
agree, that would be odd in this instance, since presumably you
would at least want to have key on the source or destination
columns.<br>
<br>
j<br>
<br>
On 12/07/2012 12:52 PM, Don Kelly wrote:<br>
</div>
<blockquote cite="mid:023101cdd4ac$27552f90$75ff8eb0$@donkelly.biz"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">This
thread confuses me. I’ve not worked with the Asterisk MySQL
CDR, but have worked with SQL for years.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Every
table should have a primary key. Is no column identified as
a PK?<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">If
there is a PK, you will not be able to designate another
column as PK.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">If
there is a PK, you don’t need to worry about Asterisk
duplicating keys in that column—the database will not permit
non-unique PKs.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">If
(and this would be really weird) the table is created with
no primary key, it shouldn’t be a problem to add the primary
key constraint to a column IF there are no nulls or
duplicates existing.<o:p></o:p></span></p>
<p class="MsoNormal"
style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D"
lang="EN">--Don</span><span style="color:#1F497D" lang="EN"><o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#1F497D"
lang="EN"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">
<a class="moz-txt-link-abbreviated" href="mailto:asterisk-users-bounces@lists.digium.com">asterisk-users-bounces@lists.digium.com</a>
[<a class="moz-txt-link-freetext" href="mailto:asterisk-users-bounces@lists.digium.com">mailto:asterisk-users-bounces@lists.digium.com</a>] <b>On
Behalf Of </b>Leandro Dardini<br>
<b>Sent:</b> Thursday, December 06, 2012 12:50 PM<br>
<b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:rwheeler@artifact-software.com">rwheeler@artifact-software.com</a>; Asterisk Users
Mailing List - Non-Commercial Discussion<br>
<b>Subject:</b> Re: [asterisk-users] CDR - Freepbx - Safe to
add primary key to table ?<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p>The reason I add a new column autoincrement is due to the
fact I trust more mysql about uniquness than asterisk. <o:p></o:p></p>
<p>Leandro<o:p></o:p></p>
<p>I am typing from my mobile phone...<o:p></o:p></p>
<div>
<p class="MsoNormal">Il giorno 06/dic/2012 19:11, "Ron
Wheeler" <<a moz-do-not-send="true"
href="mailto:rwheeler@artifact-software.com">rwheeler@artifact-software.com</a>>
ha scritto:<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">It seems like a safe thing to do.<br>
You could also ask about the impact of making an
existing column a primary key, in a MySQL forum.<br>
<br>
Leandro's solution seems to be a good one as well and
does guarantee uniqueness.<br>
<br>
<br>
<br>
Ron<br>
<br>
On 06/12/2012 12:25 PM, Leandro Dardini wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Yes, go for it. However I have added
another autoincrement column and created the primary key
on it. On the other columns I need to search I have
created just an index. <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Leandro<o:p></o:p></p>
<div>
<p class="MsoNormal">2012/12/6 Olivier <<a
moz-do-not-send="true"
href="mailto:oza_4h07@yahoo.fr" target="_blank">oza_4h07@yahoo.fr</a>><o:p></o:p></p>
<p class="MsoNormal"
style="mso-margin-top-alt:0in;margin-right:.5in;margin-bottom:0in;margin-left:.5in;margin-bottom:.0001pt">Hello,<br>
<br>
I need to develop an application that will query
(mostly reading) an existing MySQL CDR database.<br>
This database (named asteriskcdrdb) was created
during Freepbx 2.10 install on my asterisk 1.8
setup.<br>
This database has a single CDR table which is filled
by Asterisk.<br>
<br>
The tools I'm planning to use require this table to
include a Primary Key.<br>
Is it safe to Alter this table telling it to use
UniqueID column as a Primary Key ?<br>
<br>
(Sure, I'll test this on a database copy but I'm not
confident my tests will cover everything)<br>
<br>
Regards<br>
<br>
--<br>
<br>
<o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by <a class="moz-txt-link-freetext" href="http://www.api-digital.com">http://www.api-digital.com</a> --
New to Asterisk? Join us for a live introductory webinar every Thurs:
<a class="moz-txt-link-freetext" href="http://www.asterisk.org/hello">http://www.asterisk.org/hello</a>
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
<a class="moz-txt-link-freetext" href="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</a></pre>
</blockquote>
<br>
</body>
</html>