By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,659 Members | 910 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,659 IT Pros & Developers. It's quick & easy.

wrong select or insert into ?

P: n/a
hello

I have strange problem.
I write to MySQL data to table with one column of varchar(8000). I write
750000 bytes, so it get 93 records of 8000 bytes and the last - 6000bytes.
but what is strange - when I check length of this records:

select len(column_name) from table_name

this last record ( which is 6000bytes length ) isn't on 94 position, but ...
on 14 position !?
The same, when I try to reads recods:

select column name from table name

this 6000 record apear on 14 position instead on 94 position

It's important to me to get this record on proper ( last) position to not
change ( complicating ) my C++ application algoritm.

Could someone help me, please

thanks in advance

Adam

Aug 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
>> It's important to me to get this record [sic] on proper (last) position [sic] to not change (complicating ) my C++ application algoritm. <<

You never had a class or read a book on RDBMS, have you? The most
fundamental concept in SQL is that there is no ordering to table!!

Let's get back to the basics of an RDBMS. Rows are not records; fields
are not columns; tables are not files; there is no sequential access or
ordering in an RDBMS, so "first", "next" and "last" are totally
meaningless. If you want to have an ordering, you need a column for it.

Aug 22 '05 #2

P: n/a
Yes- you are right. I did it - I added a field ( lp int ) with integer from
1 to last row - and added to my question "order by lp"- there I get what I
want.
But there is some interesting - you say that there is no any ordering in
RDBMS. So why I always get this row at 14 posiotion? There must be some
"internal" ordering if SQL give me this row ALWAYS on 14 position - not on
random position ( first time on 14 , next on 20 and so on ).

best wishes

Adam

Aug 23 '05 #3

P: n/a
Without an "order by" clause in your query, you're likely to get the
rows out ordered by the clustered index, since that's the order that
they're stored on the disk. That's probably why you're getting them in
the same order everytime.

BTW, before you chime in, Celko, I don't give two shits that "order by"
is part of a cursor, not a query -- so save your breath.

Aug 23 '05 #4

P: n/a
Without ORDER BY, SQL Server is free to return results in any sequence.
This is usually the most efficient chosen by the cost-based optimizer.
Ordering of results may vary depending on indexes, statistics, number of
processors, concurrent queries, etc. The version, service pack, and hotfix
level can also influence ordering due to potential optimizer changes.
Consequently, one should never assume data will be returned in any
particular order unless ORDER BY is specified.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"adam" <er******@wp.pl> wrote in message
news:de**********@nemesis.news.tpi.pl...
Yes- you are right. I did it - I added a field ( lp int ) with integer
from
1 to last row - and added to my question "order by lp"- there I get what I
want.
But there is some interesting - you say that there is no any ordering in
RDBMS. So why I always get this row at 14 posiotion? There must be some
"internal" ordering if SQL give me this row ALWAYS on 14 position - not on
random position ( first time on 14 , next on 20 and so on ).

best wishes

Adam

Aug 24 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.