473,657 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

(primary key == index) ?

when I create a table, I always make the first column my unique-id, and make
this primary key auto-increment.
Does this mean that the table will be indexed by mysql on this key - or do I
need to explicitly do this too?

e.g.

create table note
(
note_id INTEGER(9) AUTO_INCREMENT PRIMARY KEY,
mytext varchar(255)
);

So do I need to add something to get mysql indexing on the primary key?

many thanks,
JJ
Jul 19 '05 #1
4 15453
erehwon wrote:
when I create a table, I always make the first column my unique-id, and make
this primary key auto-increment.
Does this mean that the table will be indexed by mysql on this key - or do I
need to explicitly do this too?


interesting question. I wanted to know the answer to this too, so I
looked it up in the documentation at www.mysql.com. the answer is "yes"
- the table is indexed. this can be verified by running 'SHOW INDEX FROM
<table_name>' using the mysql client.

/dave

Jul 19 '05 #2
erehwon wrote:
when I create a table, I always make the first column my unique-id, and make
this primary key auto-increment.
Does this mean that the table will be indexed by mysql on this key - or do I
need to explicitly do this too?


interesting question. I wanted to know the answer to this too, so I
looked it up in the documentation at www.mysql.com. the answer is "yes"
- the table is indexed. this can be verified by running 'SHOW INDEX FROM
<table_name>' using the mysql client.

/dave

Jul 19 '05 #3
great :o) & thanks!

JJ

"Dave Roe" <da******@email .com> wrote in message
news:DH******** ***********@new sread2.news.pas .earthlink.net. ..
erehwon wrote:
when I create a table, I always make the first column my unique-id, and make this primary key auto-increment.
Does this mean that the table will be indexed by mysql on this key - or do I need to explicitly do this too?


interesting question. I wanted to know the answer to this too, so I
looked it up in the documentation at www.mysql.com. the answer is "yes"
- the table is indexed. this can be verified by running 'SHOW INDEX FROM
<table_name>' using the mysql client.

/dave

Jul 19 '05 #4
great :o) & thanks!

JJ

"Dave Roe" <da******@email .com> wrote in message
news:DH******** ***********@new sread2.news.pas .earthlink.net. ..
erehwon wrote:
when I create a table, I always make the first column my unique-id, and make this primary key auto-increment.
Does this mean that the table will be indexed by mysql on this key - or do I need to explicitly do this too?


interesting question. I wanted to know the answer to this too, so I
looked it up in the documentation at www.mysql.com. the answer is "yes"
- the table is indexed. this can be verified by running 'SHOW INDEX FROM
<table_name>' using the mysql client.

/dave

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
17385
by: Tuhin Kumar | last post by:
Hi, Oracle give the error ORA-01418 when I try to do the following; Create unique index t1_pk on TABLE1(EntryId DESC) ; If the I try to add primary key Contraint using the above index t1_pk as below: ALTER TABLE TABLE1 ADD CONSTRAINT TABLE1_PK PRIMARY KEY (EntryId) USING INDEX t1_pk;
17
49814
by: Philip Yale | last post by:
I'm probably going to get shot down with thousands of reasons for this, but I've never really heard or read a convincing explanation, so here goes ... Clustered indexes are more efficient at returning large numbers of records than non-clustered indexes. Agreed? (Assuming the NC index doesn't cover the query, of course) Since it's only possible to have one clustered index, why is this almost always used for the primary key, when by...
4
10556
by: serge | last post by:
I ran into a table that is used a lot. Well less than 100,000 records. Maybe not a lot of records but i believe this table is used often. The table has 26 fields, 9 indexes but no Primary Key at all! There are no table relationships defined in this database, no Natural keys, only Surrogate keys in the database. 1- Maybe an odd question but is it normal to have 1/3 of the table's fields as indexes? Is this a valid question or it really
6
2090
by: Bob Stearns | last post by:
I was under the impression that the primary key had to be a unique index. Since I usually create my primary indices before my primary keys, in order to get the indices in the same schema as their tables, it is possible , by error, to create such an index without the unique attribute. DB2 UDB 8.1.5 Linux uses such an index for the primary key anyway, thus losing the unique property of the primary key. Is this a bug or a feature, i.e. a...
4
14419
by: deko | last post by:
I have a Make Table query that creates a fairly large table. The Make Table query populates the new table with one AutoNumber field (which is taken form another unrelated table as part of the query). I want to make the AutoNumber field the Primary Key: DoCmd.OpenQuery "qryXL_To" ' this is the make table query DoCmd.RunSQL "CREATE UNIQUE INDEX idxTxAcct ON tblXL_To (TxAcct_ID)" This seems to work okay, but it does not create a...
8
31533
by: Paul Hunter | last post by:
I am new to databases and thus to Access. I have a situation where I am trying to figure out how to key some tables I am working with. Consider that I have a database of my own records which are invoices I work on. These invoices are from four companies with their own invoice numbers. So, I cannot key by invoice number because there is a likelihood of invoice numbers duplicated by different companies. The records in this table of joined...
9
3904
by: sonal | last post by:
Hi all, I hv started with python just recently... and have been assigned to make an utility which would be used for data validations... In short we take up various comma separated data files for eg: area.txt, school.txt, students.txt.... and so on (ok?!?) now, 1. area code used in the school.txt must be defined in the area.txt (Primary key in area => area_code defined in area.txt & Foreign key on school => area_code defined in...
3
35381
by: vj_dba | last post by:
Hi Group, I have a Primary key in my table. It's clear Primary key wont allow duplicates, this primary key creates one index for retrival. Suppose if my table is having a Unique index also. Then what is the exact difference between the Primary key and the Unique index? Also which on data retrival..internally it uses the Primary key index
1
5333
by: mark_aok | last post by:
Hi all, I have a situation where I need to determine a specific table's primary key, and then output it. I have tried the Database Object, and the Record Object, but I've had no luck. Ideally there would be something like,
4
3130
by: codefragment | last post by:
Hi I thought that given a table with an index, primary key and clustered index any non clustered index look ups would go via the clustered index and the primary key is irrelevant? (sql server 2000). A colleague has said that the primary key should be the clustered index because all index lookups will go via the primary key. Is this right? I thought the primary key was nothing more than a constraint on what data can be entered into the...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6166
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.