开发者

How to show the table created date in android database and how to delete that table according to some condition on date?

I know all stuff rega开发者_StackOverflow社区rding create table and update all, and delete it. But now i want to delete some tables whos created date is less then 2 weeks. So can anybudy tell me how to fetch such type of tables and from there i want to delete the table whoes date is less then 2 weeks. Please help me regarding it. . . Thanks.


For this you have to maintain one new table (creation_date) with all tables name and their creation dates

Whenever you want to delete table whose date is less then 2 weeks at that time first fetch the system's date & time. After that count the date less then 2 weeks from current date;

Using the 2 weeks later date query in the table whose contain all table name as below

Select table_name From creation_date Where crnt_date < date

Using this you can get all the table names whose created before 2 weeks

After this you can fire query for each table for delete that table like below

Drop Table table_name


AFAIK sqlite (I guess you're talking about it) does not keep table creation date as part of the database metadata accessible trough the sqlite_master table. But it would be trivial to create an extra table to keep track of creation dates if this is what you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜