"Android Interview Treasure" study notes (sixth: database)

Source: Internet
Author: User

How do I copy the contents of table1 to table2?

CREATE TABLE Table2 as SELECT * FROM table1;

SQL statement to create a view?

Create view if not exists view1 as SELECT * FROM table1;

What are the return values of ABS (X) in several cases?
X is positive and 0: returns x;

X is negative: returns-X;

X is null and returns null;

Not numeric: returns 0;

Out of range: overflow error.


How do I get the number of record rows affected by the last SQL statement execution?

Select changes ();


What value does length (X) return in the following cases?

Blob: Returns the number of bytes in the binary data;

NULL: Returns NULL;

Numeric value: Converts numeric values to string processing.


The role of the like function:

SELECT * FROM table1 where like ('%bill% ', name)


Use of the NULLIF function:

When x and Y are not the same, the NULLIF function returns x, or null if the same is true.


substr function Usage:

Select substr (' ABCDEFG ', 2, 3)


How do I get the data type of the current field?

Select typeof (Field1) from table1;


Which date and time functions does SQLite support?
Date, Time, DateTime, Julianday, strftime

Select DateTime (' Now ');
Result: 2006-10-17 12:55:54

Select DateTime (' 2006-10-17 ');
Result: 2006-10-17 12:00:00

Select DateTime (' 2006-10-17 00:20:00 ', ' +1 hour ', ' -12 minute ');
Result: 2006-10-17 01:08:00

Select Date (' 2006-10-17 ', ' +1 Day ', ' +1 Year ');
Results: 2007-10-18


How do I output the current date and time?

Select Date (' Now ');

Select time (' Now ');


The arithmetic rules of the AVG (X) function?
X is null:null;

X is a string or blob: The convertible is converted to a numeric value, otherwise treated as 0;

All fields are null:null;


When do I call the Onupgrade method?

The database file exists and the current version number is higher than the version number when it was last created or promoted.


How do I publish a SQLite database with data with the APK program?
http://blog.csdn.net/zz_mm/article/details/7642127


What is a db4o database?
Database for objects, open source object-oriented databases


How do I save an object instance to the Db4o database?

Student Student = new Student (1, "Mike", 100);

Db.store (student);

Db.commit ();


How do I query, modify, and delete data through db4o?

Http://wenku.baidu.com/link?url=MTyzcHMgymzcBCQOzm3y8vqiVp0Rh-sEuzAtckXFwXKw8xaJ-lk-7WXdcIB5_ Hhlae0haklfdwgplfa0vrxfwuvckfwr5lelcdmisexr6t3



"Android Interview Treasure" study notes (sixth: database)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.