.table
查看数据库所有的表格名称
.h on
可查看表中的字段名
.q
正常退出数据库
select * from user
获取user数据表中所有的数据
update user set value='1' where id='0';
将user数据表中 id等于0,字段名为value的值设置为1
扫描二维码关注公众号,回复:
3940827 查看本文章
.schema
在没有参数的情况,它会显示最初用于创建数据库的CREATE TABLE和CREATE INDEX的SQL语句
创建数据表,创建一个snmp表,成员如下
struct snmp
{
int v1_enable;
int v2c_enable;
char write_community[MAX_LEN_64];
char read_community[MAX_LEN_64];
int v3_enable;
char read_security_name[MAX_LEN_64];
int read_level_security;//0=auth,priv 1=auth,no priv 2=no auth,no priv
int read_auth_algorithm;//0=MD5 1=SHA
char read_auth_password[MAX_LEN_64];
int read_pri_algorithm;//0=DES 1=AES
char read_pri_password[MAX_LEN_64];
char write_security_name[MAX_LEN_64];
int write_level_security;//0=auth,priv 1=auth,no priv 2=no auth,no priv
int write_auth_algorithm;//0=MD5 1=SHA
char write_auth_password[MAX_LEN_64];
int write_pri_algorithm;//0=DES 1=AES
char write_pri_password[MAX_LEN_64];
int port;
};
CREATE TABLE snmp ("v1_enable" INTEGER, "v2c_enable" INTEGER, "read_community" TEXT NOT NULL, "write_community" TEXT NOT NULL, "v3_enable" INTEGER, "read_name" TEXT NOT NULL, "read_level" INTEGER, "read_auth_type" INTEGER, "read_auth_psw" TEXT NOT NULL, "read_pri_type" INTEGER, "read_pri_psw" TEXT NOT NULL, "write_name" TEXT NOT NULL, "write_level" INTEGER, "write_auth_type" INTEGER, "write_auth_psw" TEXT NOT NULL, "write_pri_type" INTEGER, "write_pri_psw" TEXT NOT NULL, "port" INTEGER);
insert into snmp values('0', '0', 'public', 'private', '0', '', '2', '0', '', '0', '', '', '2', '0', '', '0', '', '161');
插入新的数据也可以这样写:先把字段名写前面,之后用values把所有的数据补充上
insert into vca_people_event(id,enable,tri_alarms,tri_channels_ex) values(0,0,0,'1000000000000000000000000000000000000000000000000000000000000000');
在原有的数据表中插入新的字段:在network中新增若干字段
alter table network add column "lan1_ip6_address" TEXT default "";
alter table network add column "lan1_ip6_netmask" TEXT default "";
alter table network add column "lan1_ip6_gateway" TEXT default "";
alter table network add column "lan2_ip6_address" TEXT default "";
alter table network add column "lan2_ip6_netmask" TEXT default "";
alter table network add column "lan2_ip6_gateway" TEXT default "";
alter table network add column "lan1_ip6_dhcp" INTEGER;
alter table network add column "lan2_ip6_dhcp" INTEGER;
alter table network add column "bond0_ip6_dhcp" INTEGER;
alter table network add column "bond0_ip6_address" TEXT default "";
alter table network add column "bond0_ip6_netmask" TEXT default "";
alter table network add column "bond0_ip6_gateway" TEXT default "";