在SQLite数据库中创建一张“表”

在SQLite数据库中创建一张“表”

    在SQLite Exoert professional软件中有两种方法可以创建表,一种是利用Design创建,另外一种是直接使用SQL语句创建。



方法一:利用Design创建
    1. 选中数据库右键,点击“New Table” ⟶ 2. 添加列:点击“Design”,点击“Insert”,在弹出的对话框内设置Columns属性 ⟶ 3. 设置主键:点击“Primary Key”,点击“Insert”,在下拉菜单中选择需要设置为主键的列名 ⟶ 4. 如需要继续设置索引、触发等条件可以继续在后面的选项中添加 ⟶ 5. 点击“General”,输入Table Name,点击“Apply” ⟶ 6. 添加数据:点击“Data”,点击“+”,选中列名右键,点击“Record Editor”,输入内容。
图
方法二:利用SQL语句创建
例如:

/*创建表名为"information"的表结构*/
create table demo(id integer not null primary key, '姓名' text not null, '性别' text not null, '年龄' integer not null);
/*在表中添加数据*/
insert into demo('姓名','性别','年龄') values('张三','男',23),('李四','女',18),('王五','男',20),('赵六','男',25);
/*查询information表中的数据*/
select * from information;

图二

猜你喜欢

转载自blog.csdn.net/yga_airspace/article/details/81986344
今日推荐