暂留实例

在数据库服务器192.168.4.50上做如下练习
把/etc/passwd文件的内容存储到userdb库下的usertab表里,并做如下配置:
MariaDB [(none)]> create table userdb.usertab(name char(100) not null, password char(1) default "x" not null, uid int(11) not null, gid int(11) not null, comment char(200) not null, homedir char(200) not null, shell char(200) not null);

MariaDB [(none)]> system cp /etc/passwd /mydata/
MariaDB [(none)]> system ls /mydata/passwd;

MariaDB [(none)]> load data infile "/mydata/passwd"
-> into table userdb.usertab
-> fields terminated by ":"
-> lines terminated by "\n";

MariaDB [(none)]> select * from userdb.usertab;
MariaDB [(none)]> desc userdb.usertab;
+----------+-----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-----------+------+-----+---------+-------+
| name | char(100) | NO | | NULL | |
| password | char(1) | NO | | x | |
| uid | int(11) | NO | | NULL | |
| gid | int(11) | NO | | NULL | |
| comment | char(200) | NO | | NULL | |
| homedir | char(200) | NO | | NULL | |
| shell | char(200) | NO | | NULL | |
+----------+-----------+------+-----+---------+-------+
###################################################################################
常见错误:导入文件时报错

mysql> load data infile "/mydata/passwd" 当前想要从/mydata/里导入到数据库
-> into table userdb.usertab
-> fields terminated by ":"
-> lines terminated by "\n";
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement 提示secure-file-priv这个限制了


mysql> show variables like "secure_file_priv";
+------------------+---------+
| Variable_name | Value |
+------------------+---------+
| secure_file_priv | /mybak/ | 当前默认的导入文件目录/mybak/,上面写的是/mydata/
+------------------+---------+

改称成默认的目录就对了
mysql> load data infile "/mybak/passwd" into table userdb.usertab fields terminated by ":" lines terminated by "\n";
###################################################################################
6 在用户名字段下方添加s_year字段 存放出生年份 默认值是1990
MariaDB [(none)]> alter table userdb.usertab modify s_year int default 1990 not null after age;
MariaDB [(none)]> desc userdb.usertab;
+----------+-----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-----------+------+-----+---------+-------+
| name | char(100) | NO | | NULL | |
| s_year | int(11) | NO | | 1990 | |
| password | char(1) | NO | | x | |
| uid | int(11) | NO | | NULL | |
| gid | int(11) | NO | | NULL | |
| comment | char(200) | NO | | NULL | |
| homedir | char(200) | NO | | NULL | |
| shell | char(200) | NO | | NULL | |
+----------+-----------+------+-----+---------+-------+

7 在用户名字段下方添加字段名sex 字段值只能是girl 或boy 默认值是 boy
MariaDB [(none)]> alter table userdb.usertab add sex set("girl","boy") default "boy" not null after name;
MariaDB [(none)]> desc userdb.usertab;
+----------+-------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------------+------+-----+---------+-------+
| name | char(100) | NO | | NULL | |
| sex | set('girl','boy') | NO | | boy | |
| s_year | int(11) | YES | | 1990 | |
| password | char(1) | NO | | x | |
| uid | int(11) | NO | | NULL | |
| gid | int(11) | NO | | NULL | |
| comment | char(200) | NO | | NULL | |
| homedir | char(200) | NO | | NULL | |
| shell | char(200) | NO | | NULL | |
+----------+-------------------+------+-----+---------+-------+

8 在sex字段下方添加 age字段 存放年龄 不允许输入负数。默认值 是 21
MariaDB [(none)]> alter table userdb.usertab add age tinyint unsigned default 21 not null after sex;
在计算机中,可以区分正负的类型,称为有符号类型,无正负的类型(只有正值),称为无符号类型

MariaDB [userdb]> desc userdb.usertab;
+----------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------------------+------+-----+---------+-------+
| name | char(100) | NO | | NULL | |
| sex | set('girl','boy') | NO | | boy | |
| age | tinyint(3) unsigned | NO | | 21 | |
| s_year | int(11) | NO | | 1990 | |
| password | char(1) | NO | | x | |
| uid | int(11) | NO | | NULL | |
| gid | int(11) | NO | | NULL | |
| comment | char(200) | NO | | NULL | |
| homedir | char(200) | NO | | NULL | |
| shell | char(200) | NO | | NULL | |
+----------+---------------------+------+-----+---------+-------+

9 把id字段值是10到50之间的用户的性别修改为 girl
MariaDB [userdb]> update userdb.usertab set sex="girl" where uid>10 and uid<50;
MariaDB [(none)]> select name,uid,sex from userdb.usertab where sex="girl" order by uid;
+----------+-----+------+
| name | uid | sex |
+----------+-----+------+
| operator | 11 | girl |
| games | 12 | girl |
| ftp | 14 | girl |
| mysql | 27 | girl |
| rpcuser | 29 | girl |
| rpc | 32 | girl |
| ntp | 38 | girl |
| gdm | 42 | girl |
+----------+-----+------+

10 统计性别是girl的用户有多少个。
MariaDB [(none)]> select count(sex) from userdb.usertab where sex="girl";
+------------+
| count(sex) |
+------------+
| 8 |
+------------+

12 查看性别是girl用户里 uid号 最大的用户名 叫什么。
MariaDB [(none)]> select name,sex,max(uid) from userdb.usertab where sex="girl";
+----------+------+----------+
| name | sex | max(uid) |
+----------+------+----------+
| operator | girl | 42 |
+----------+------+----------+

13 添加一条新记录只给name、uid 字段赋值 值为rtestd 1000
MariaDB [(none)]> insert into userdb.usertab(name,uid) values("rtestd",1000);
MariaDB [(none)]> select * from userdb.usertab where name="rtestd";
+--------+-----+-----+--------+----------+------+-----+---------+---------+-------+
| name | sex | age | s_year | password | uid | gid | comment | homedir | shell |
+--------+-----+-----+--------+----------+------+-----+---------+---------+-------+
| rtestd | boy | 21 | 1990 | x | 1000 | 0 | | | |
+--------+-----+-----+--------+----------+------+-----+---------+---------+-------+

添加一条新记录只给name、uid 字段赋值 值为rtest2d 2000
MariaDB [(none)]> insert into userdb.usertab(name,uid) values("rtest2d",2000);
MariaDB [(none)]> select * from userdb.usertab where name="rtest2d";
+---------+-----+-----+--------+----------+------+-----+---------+---------+-------+
| name | sex | age | s_year | password | uid | gid | comment | homedir | shell |
+---------+-----+-----+--------+----------+------+-----+---------+---------+-------+
| rtest2d | boy | 21 | 1990 | x | 2000 | 0 | | | |
+---------+-----+-----+--------+----------+------+-----+---------+---------+-------+

14 显示uid 是四位数的用户的用户名和uid值。
MariaDB [(none)]> select name,uid from userdb.usertab where uid like "____";
+---------+------+
| name | uid |
+---------+------+
| lisi | 1000 |
| rtestd | 1000 |
| rtest2d | 2000 |
+---------+------+

MariaDB [(none)]> select name,uid from userdb.usertab where uid regexp '^....$';
+---------+------+
| name | uid |
+---------+------+
| lisi | 1000 |
| rtestd | 1000 |
| rtest2d | 2000 |
+---------+------+

15 显示名字是以字母r 开头 且是以字母d结尾的用户名和uid。
MariaDB [(none)]> select name,uid from userdb.usertab where name like "r%d";
+---------+------+
| name | uid |
+---------+------+
| radvd | 75 |
| rtestd | 1000 |
| rtest2d | 2000 |
+---------+------+

MariaDB [(none)]> select name,uid from userdb.usertab where name regexp "^r.*d$";
+---------+------+
| name | uid |
+---------+------+
| radvd | 75 |
| rtestd | 1000 |
| rtest2d | 2000 |
+---------+------+

16 查看是否有 名字以字母a开头 并且是 以字母c结尾的用户。
MariaDB [(none)]> select name from userdb.usertab where name regexp "^a.*c$";
MariaDB [(none)]> select name from userdb.usertab where name like "a%c";

8 把gid 在100到500间用户的家目录修改为/root
MariaDB [(none)]> select name,gid,homedir from userdb.usertab where gid>100 and gid<500 order by gid;
+-----------------+-----+---------+
| name | gid | homedir |
+-----------------+-----+---------+
| qemu | 107 | /root |
| usbmuxd | 113 | /root |
| pulse | 171 | /root |
| rtkit | 172 | /root |
| abrt | 173 | /root |
| systemd-network | 192 | /root |
+-----------------+-----+---------+

9 把用户是 root 、 bin 、 sync 用户的shell 修改为 /sbin/nologin
MariaDB [(none)]> update userdb.usertab set shell="/sbin/nologin" where name in ("root","bin","sync");
MariaDB [(none)]> select name,shell from userdb.usertab where name in ("root","bin","sync");
+------+---------------+
| name | shell |
+------+---------------+
| root | /sbin/nologin |
| bin | /sbin/nologin |
| sync | /sbin/nologin |
+------+---------------+

10 查看 gid 小于10的用户 都使用那些shell
MariaDB [(none)]> select name,gid,shell from userdb.usertab where gid<10 order by gid;
+----------+-----+----------------+
| name | gid | shell |
+----------+-----+----------------+
| root | 0 | /sbin/nologin |
| rtestd | 0 | |
| operator | 0 | /sbin/nologin |
| halt | 0 | /sbin/halt |
| shutdown | 0 | /sbin/shutdown |
| sync | 0 | /sbin/nologin |
| rtest2d | 0 | |
| bin | 1 | /sbin/nologin |
| daemon | 2 | /sbin/nologin |
| adm | 4 | /sbin/nologin |
| lp | 7 | /sbin/nologin |
+----------+-----+----------------+

12 删除 名字以字母d开头的用户。
MariaDB [(none)]> delete from userdb.usertab where name like "d%";
MariaDB [(none)]> delete from userdb.usertab where name regexp '^d';

13 查询 gid 最大的前5个用户 使用的 shell
MariaDB [(none)]> select name,gid,shell from userdb.usertab order by gid desc limit 5;
+----------------+-------+---------------+
| name | gid | shell |
+----------------+-------+---------------+
| nfsnobody | 65534 | /sbin/nologin |
| lisi | 1000 | /bin/bash |
| polkitd | 998 | /sbin/nologin |
| libstoragemgmt | 996 | /sbin/nologin |
| colord | 995 | /sbin/nologin |
+----------------+-------+---------------+

14 查看那些用户没有家目录
MariaDB [(none)]> select name,homedir from userdb.usertab where homedir="";
+---------+---------+
| name | homedir |
+---------+---------+
| rtestd | |
| rtest2d | |
+---------+---------+

15 把gid号最小的前5个用户信息保存到/mybak/min5.txt文件里。
MariaDB [(none)]> show variables like "secure_file_priv";
+------------------+-----------------+
| Variable_name | Value |
+------------------+-----------------+
| secure_file_priv | /var/lib/mysql/ |
+------------------+-----------------+

# vim /etc/my.cnf
[mysqld]
secure_file_priv="/mybak" 先指定数据库默认导出的文件存储目录
... ...

# mkdir /mybak
# chown mysql:mysql /mybak 要有目录权限
# ls -ld /mybak
drwxr-xr-x. 2 mysql mysql 6 11月 24 20:50 /mybak
# systemctl restart mariadb
# mysql -uroot -p123qqq...A

MariaDB [(none)]> show variables like "secure_file_priv";
+------------------+---------+
| Variable_name | Value |
+------------------+---------+
| secure_file_priv | /mybak/ |
+------------------+---------+

MariaDB [(none)]> select * from userdb.usertab order by gid limit 5;
+----------+------+-----+--------+----------+------+-----+----------+---------+----------------+
| name | sex | age | s_year | password | uid | gid | comment | homedir | shell |
+----------+------+-----+--------+----------+------+-----+----------+---------+----------------+
| root | boy | 21 | 1990 | x | 0 | 0 | root | /root | /sbin/nologin |
| operator | girl | 21 | 1990 | x | 11 | 0 | operator | /root | /sbin/nologin |
| rtest2d | boy | 21 | 1990 | x | 2000 | 0 | | | |
| halt | boy | 21 | 1990 | x | 7 | 0 | halt | /sbin | /sbin/halt |
| shutdown | boy | 21 | 1990 | x | 6 | 0 | shutdown | /sbin | /sbin/shutdown |
+----------+------+-----+--------+----------+------+-----+----------+---------+----------------+

MariaDB [(none)]> select * from userdb.usertab order by gid limit 5 into outfile "/mybak/min5.txt";

使用useradd 命令添加登录系统的用户 名为lucy
MariaDB [(none)]> system useradd lucy
MariaDB [(none)]> system id lucy
uid=1001(lucy) gid=1001(lucy) 组=1001(lucy)

16 把lucy用户的信息 添加到user1表里

 

 


17 删除表中的 comment 字段
MariaDB [(none)]> alter table userdb.usertab drop comment;
MariaDB [(none)]> desc userdb.usertab;
+----------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------------------+------+-----+---------+-------+
| name | char(100) | NO | | NULL | |
| sex | set('girl','boy') | NO | | boy | |
| age | tinyint(3) unsigned | NO | | 21 | |
| s_year | int(11) | NO | | 1990 | |
| password | char(1) | NO | | x | |
| uid | int(11) | NO | | NULL | |
| gid | int(11) | NO | | NULL | |
| homedir | char(200) | NO | | NULL | |
| shell | char(200) | NO | | NULL | |
+----------+---------------------+------+-----+---------+-------+

18 设置表中所有字段值不允许为空
MariaDB [(none)]> alter table userdb.usertab
-> modify name char(100) not null,
-> modify sex set("girl","boy") default "boy" not null,
-> modify age tinyint unsigned default 21 not null,
-> modify s_year int default 1990 not null,
-> modify password char(1) default "x" not null,
-> modify uid int not null,
-> modify gid int not null,
-> modify homedir char(200) not null,
-> modify shell char(200) not null;

MariaDB [(none)]> desc userdb.usertab;
+----------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------------------+------+-----+---------+-------+
| name | char(100) | NO | | NULL | |
| sex | set('girl','boy') | NO | | boy | |
| age | tinyint(3) unsigned | NO | | 21 | |
| s_year | int(11) | NO | | 1990 | |
| password | char(1) | NO | | x | |
| uid | int(11) | NO | | NULL | |
| gid | int(11) | NO | | NULL | |
| homedir | char(200) | NO | | NULL | |
| shell | char(200) | NO | | NULL | |
+----------+---------------------+------+-----+---------+-------+

如果当前正在使用的字段有空值,就会报错,无法修改类型为默认非空。
ERROR 1138 (22004): Invalid use of NULL value

19 删除root 用户家目录字段的值
MariaDB [(none)]> update userdb.usertab set homedir=""where name="root";
MariaDB [(none)]> select name,homedir from userdb.usertab where name="root";
+------+---------+
| name | homedir |
+------+---------+
| root | |
+------+---------+

20 显示 gid 大于500的用户的用户名 家目录和使用的shell
MariaDB [(none)]> select gid,name,homedir,shell from userdb.usertab where gid>500 order by gid;
+-------+---------------------+---------------------------+---------------+
| gid | name | homedir | shell |
+-------+---------------------+---------------------------+---------------+
| 987 | gnome-initial-setup | /run/gnome-initial-setup/ | /sbin/nologin |
| 990 | setroubleshoot | /var/lib/setroubleshoot | /sbin/nologin |
| 991 | geoclue | /var/lib/geoclue | /sbin/nologin |
| 993 | chrony | /var/lib/chrony | /sbin/nologin |
| 995 | colord | /var/lib/colord | /sbin/nologin |
| 996 | libstoragemgmt | /var/run/lsm | /sbin/nologin |
| 998 | polkitd | / | /sbin/nologin |
| 1000 | lisi | /home/lisi | /bin/bash |
| 65534 | nfsnobody | /var/lib/nfs | /sbin/nologin |
+-------+---------------------+---------------------------+---------------+

21 删除uid大于100的用户记录
MariaDB [(none)]> delete from userdb.usertab where uid>100;

22 显示uid号在10到30区间的用户有多少个。
MariaDB [(none)]> select count(uid) from userdb.usertab where uid>10 and uid<30;
+------------+
| count(uid) |
+------------+
| 5 |
+------------+

23 显示uid号是100以内的用户使用shell的类型。
MariaDB [(none)]> select distinct shell from userdb.usertab where uid<100;
+----------------+
| shell |
+----------------+
| /sbin/nologin |
| /sbin/shutdown |
| /sbin/halt |
+----------------+

24 显示uid号最小的前10个用户的信息。
MariaDB [(none)]> select * from userdb.usertab order by uid limit 10;
+----------+------+-----+--------+----------+-----+-----+-----------------+----------------+
| name | sex | age | s_year | password | uid | gid | homedir | shell |
+----------+------+-----+--------+----------+-----+-----+-----------------+----------------+
| root | boy | 21 | 1990 | x | 0 | 0 | | /sbin/nologin |
| bin | boy | 21 | 1990 | x | 1 | 1 | /bin | /sbin/nologin |
| adm | boy | 21 | 1990 | x | 3 | 4 | /var/adm | /sbin/nologin |
| lp | boy | 21 | 1990 | x | 4 | 7 | /var/spool/lpd | /sbin/nologin |
| sync | boy | 21 | 1990 | x | 5 | 0 | /sbin | /sbin/nologin |
| shutdown | boy | 21 | 1990 | x | 6 | 0 | /sbin | /sbin/shutdown |
| halt | boy | 21 | 1990 | x | 7 | 0 | /sbin | /sbin/halt |
| mail | boy | 21 | 1990 | x | 8 | 12 | /var/spool/mail | /sbin/nologin |
| operator | girl | 21 | 1990 | x | 11 | 0 | /root | /sbin/nologin |
| games | girl | 21 | 1990 | x | 12 | 100 | /usr/games | /sbin/nologin |
+----------+------+-----+--------+----------+-----+-----+-----------------+----------------+

25 显示表中第10条到第15条记录

 

 

26 显示uid号小于50且名字里有字母a 用户的详细信息
MariaDB [(none)]> select * from userdb.usertab where uid<50 and name like "%a%";
MariaDB [(none)]> select * from userdb.usertab where uid<50 and name regexp "a";
+----------+------+-----+--------+----------+-----+-----+-----------------+---------------+
| name | sex | age | s_year | password | uid | gid | homedir | shell |
+----------+------+-----+--------+----------+-----+-----+-----------------+---------------+
| adm | boy | 21 | 1990 | x | 3 | 4 | /var/adm | /sbin/nologin |
| halt | boy | 21 | 1990 | x | 7 | 0 | /sbin | /sbin/halt |
| mail | boy | 21 | 1990 | x | 8 | 12 | /var/spool/mail | /sbin/nologin |
| operator | girl | 21 | 1990 | x | 11 | 0 | /root | /sbin/nologin |
| games | girl | 21 | 1990 | x | 12 | 100 | /usr/games | /sbin/nologin |
+----------+------+-----+--------+----------+-----+-----+-----------------+---------------+

27 只显示用户 root bin daemon 3个用户的详细信息。
MariaDB [(none)]> select * from userdb.usertab where name in ("root","bin","daemon");
+------+-----+-----+--------+----------+-----+-----+---------+---------------+
| name | sex | age | s_year | password | uid | gid | homedir | shell |
+------+-----+-----+--------+----------+-----+-----+---------+---------------+
| root | boy | 21 | 1990 | x | 0 | 0 | | /sbin/nologin |
| bin | boy | 21 | 1990 | x | 1 | 1 | /bin | /sbin/nologin |
+------+-----+-----+--------+----------+-----+-----+---------+---------------+

28 显示除root用户之外所有用户的详细信息。
MariaDB [(none)]> select * from userdb.usertab where name!="root";

29 统计username 字段有多少条记录
MariaDB [(none)]> select count(name) from userdb.usertab;
+-------------+
| count(name) |
+-------------+
| 23 |
+-------------+

30 显示名字里含字母c 用户的详细信息
MariaDB [(none)]> select * from userdb.usertab where name regexp 'c';
MariaDB [(none)]> select * from userdb.usertab where name like "%c%";
#####################################################################################################
31 在sex字段下方添加名为pay的字段,用来存储工资,默认值 是5000.00
MariaDB [(none)]> alter table userdb.usertab
-> add pay int default "5000.00" after sex;

MariaDB [(none)]> desc userdb.usertab;
+----------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------------------+------+-----+---------+-------+
| name | char(100) | NO | | NULL | |
| sex | set('girl','boy') | NO | | boy | |
| pay | int(11) | YES | | 5000 | |
| age | tinyint(3) unsigned | NO | | 21 | |
| s_year | int(11) | NO | | 1990 | |
| password | char(1) | NO | | x | |
| uid | int(11) | NO | | NULL | |
| gid | int(11) | NO | | NULL | |
| homedir | char(200) | NO | | NULL | |
| shell | char(200) | NO | | NULL | |
+----------+---------------------+------+-----+---------+-------+

32 把所有女孩的工资修改为10000
MariaDB [(none)]> update userdb.usertab set pay=10000 where sex="girl";
MariaDB [(none)]> select name,sex,pay from userdb.usertab where sex="girl";
+----------+------+-------+
| name | sex | pay |
+----------+------+-------+
| operator | girl | 10000 |
| games | girl | 10000 |
| ftp | girl | 10000 |
| rpc | girl | 10000 |
| rpcuser | girl | 10000 |
| gdm | girl | 10000 |
| ntp | girl | 10000 |
| mysql | girl | 10000 |
+----------+------+-------+

33 把root用户的工资修改为30000
MariaDB [(none)]> update userdb.usertab set pay=30000 where name="root";
MariaDB [(none)]> select name,pay from userdb.usertab where name="root";
+------+-------+
| name | pay |
+------+-------+
| root | 30000 |
+------+-------+

给adm用户涨500元工资
MariaDB [(none)]> select name,pay from userdb.usertab where name="adm";
+------+------+
| name | pay |
+------+------+
| adm | 5000 |
+------+------+

MariaDB [(none)]> update userdb.usertab set pay=pay+500 where name="adm";
MariaDB [(none)]> select name,pay from userdb.usertab where name="adm";
+------+------+
| name | pay |
+------+------+
| adm | 5500 |
+------+------+

34 查看所有用户的名字和工资
MariaDB [(none)]> select name,pay from userdb.usertab;
+----------+-------+
| name | pay |
+----------+-------+
| root | 30000 |
| bin | 5000 |
| adm | 5500 |
| lp | 5000 |
| sync | 5000 |
| shutdown | 5000 |
| halt | 5000 |
| mail | 5000 |
| operator | 10000 |
| games | 10000 |
| ftp | 10000 |
| nobody | 5000 |
| rpc | 10000 |
| radvd | 5000 |
| tss | 5000 |
| rpcuser | 10000 |
| gdm | 10000 |
| sshd | 5000 |
| avahi | 5000 |
| postfix | 5000 |
| ntp | 10000 |
| tcpdump | 5000 |
| mysql | 10000 |
+----------+-------+

35 查看工资字段的平均值
MariaDB [(none)]> select avg(pay) from userdb.usertab;
+-----------+
| avg(pay) |
+-----------+
| 7847.8261 |
+-----------+

36 查看工资字段值小于平均工资的用户 是谁。
MariaDB [(none)]> select name,pay from userdb.usertab where pay<(select avg(pay) from userdb.usertab);
+----------+------+
| name | pay |
+----------+------+
| bin | 5000 |
| adm | 5500 |
| lp | 5000 |
| sync | 5000 |
| shutdown | 5000 |
| halt | 5000 |
| mail | 5000 |
| nobody | 5000 |
| radvd | 5000 |
| tss | 5000 |
| sshd | 5000 |
| avahi | 5000 |
| postfix | 5000 |
| tcpdump | 5000 |
+----------+------+

查看女生里谁的uid号最大
MariaDB [(none)]> select name,sex,max(uid) from userdb.usertab where sex="girl";
+----------+------+----------+
| name | sex | max(uid) |
+----------+------+----------+
| operator | girl | 42 |
+----------+------+----------+

38 查看bin用户的uid gid 字段的值 及 这2个字段相加的和
MariaDB [(none)]> select name,uid,gid,uid+gid from userdb.usertab where name="bin";
+------+-----+-----+---------+
| name | uid | gid | uid+gid |
+------+-----+-----+---------+
| bin | 1 | 1 | 2 |
+------+-----+-----+---------+

 

posted @ 2019-04-30 22:18  安于夏  阅读(233)  评论(0编辑  收藏  举报