今天来学资料库相关的语法在 Android 中,通常使用 SQLite 来作为内嵌资料库
练习相关的语法
CREATE TABLE IF NOT EXISTS user_info(
_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name VARCHAR NOT NULL,
age INTEGER NOT NULL,
height LONG NOT NULL,
weight FLOAT NOT NULL,
married INTEGER NOT NULL,
update_time VARCHAR NOT NULL);
DROP TABLE IF EXISTS user_info;
ALTER TABLE user_info ADD COLUMN phone VARCHAR;
INSERT INTO user_info(name,age,height,weight,married,update_time) VALUES(\'张三\',60,170,68,1,\'20241209\');
INSERT INTO user_info(name,age,height,weight,married,update_time) VALUES(\'李四\',35,175,60,0,\'20241209\');
INSERT INTO user_info(name,age,height,weight,married,update_time) VALUES(\'王五\',18,189,70,0,\'20241209\');
DELETE FROM user_info WHERE name=\'张三\';
UPDATE user_info SET married=1 WHERE name=\'王五\';
SELECT married FROM user_info WHERE name=\'王五\';
SELECT * FROM user_info ORDER BY age ASC;
SELECT * FROM user_info ORDER BY age DESC;
学会基本使用之后 就可以在android里用资料库啦