6

I have a table people (name, address, phone), my table have 2000+ rows. I want to delete 1000 rows. How's about the query?

0

2 Answers 2

10

I assume you want to delete "first 1000 rows" given the unsorted order of the result of "select" query with no sorting arguments and no criteria, in which case you are doing something wrong.

But, as an academic exercise, here is how you'd do it. All rows in an SQLite have rowid field, which you can use to find where those 1000 rows end.

sqlite> create table t(s string);
sqlite> insert into t values('a1');
sqlite> insert into t values('a2');
sqlite> insert into t values('a3');
sqlite> insert into t values('a4');
sqlite> select * from t;
a1
a2
a3
a4
sqlite> delete from t where rowid < (select rowid from t limit 2,1);
sqlite> select * from t;
a3
a4
Sign up to request clarification or add additional context in comments.

Comments

5

http://www.sqlite.org/lang_delete.html

If you had the SQLite update delete limit enabled

Delete from your_table 
where any_filter_you_wanted_as_well 
order by if_you_have_a_preference
limit 1000

1 Comment

I'm really feel frustrating when look at your query (sorry I'm sql newbie!) I try but I can't get the result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.