标签:big order 结构 delete img 5.5 常用函数 中文编码 一个
MariaDB [(none)]> select version(),current_date();
+----------------+----------------+
| version() | current_date() |
+----------------+----------------+
| 5.5.60-MariaDB | 2018-08-29 |
+----------------+----------------+
1 row in set (0.00 sec)
SELECT VERSION() AS name; //可设置中文,通过单引号
select 字段 as 字段别名;
例如:select version() as '版本号';
MariaDB [(none)]> select version() as '版本号';
+----------------+
| 版本号 |
+----------------+
| 5.5.60-MariaDB |
+----------------+
1 row in set (0.00 sec)
MariaDB [(none)]> select (20+5)*4;
+----------+
| (20+5)*4 |
+----------+
| 100 |
+----------+
1 row in set (0.00 sec)
MariaDB [(none)]> select
-> user()
-> ,
-> now()
-> ;
+----------------+---------------------+
| user() | now() |
+----------------+---------------------+
| root@localhost | 2018-08-29 21:59:39 |
+----------------+---------------------+
1 row in set (0.00 sec)
MariaDB [(none)]> select user();select now();
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)
+---------------------+
| now() |
+---------------------+
| 2018-08-29 22:01:49 |
+---------------------+
1 row in set (0.00 sec)
MariaDB [(none)]> show database
-> \c
MariaDB [(none)]> exit;
Bye
[root@centos ~]#
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]> use test;
Database changed
MariaDB [test]> select database();
+------------+
| database() |
+------------+
| test |
+------------+
1 row in set (0.00 sec)
MariaDB [test]> SET NAMES gbk; --set names utf8;
Query OK, 0 rows affected (0.00 sec)
MariaDB [test]> show tables;
Empty set (0.00 sec)
MariaDB [test]> select now() from dual;
+---------------------+
| now() |
+---------------------+
| 2018-08-29 22:16:05 |
+---------------------+
1 row in set (0.00 sec)
MariaDB [test]> create database book;
Query OK, 1 row affected (0.00 sec)
MariaDB [book]> create table users(
-> username varchar(20) not null,
-> sex char(1),
-> birth datetime
-> );
Query OK, 0 rows affected (0.01 sec)
MariaDB [book]> desc users; --describe users;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| username | varchar(20) | NO | | NULL | |
| sex | char(1) | YES | | NULL | |
| birth | datetime | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
MariaDB [book]> INSERT INTO users (username,sex,birth) VALUES ('Lee','x',NOW());
Query OK, 1 row affected (0.00 sec)
MariaDB [book]> SELECT * FROM users WHERE username = 'Lee';
+----------+------+---------------------+
| username | sex | birth |
+----------+------+---------------------+
| Lee | x | 2018-08-29 22:20:38 |
+----------+------+---------------------+
1 row in set (0.00 sec)
MariaDB [book]> UPDATE users SET sex = '男' WHERE username='Lee';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
MariaDB [book]> DELETE FROM users WHERE username='Lee';
Query OK, 1 row affected (0.00 sec)
MariaDB [book]> SELECT * FROM users ORDER BY birth DESC; --正序
Empty set (0.00 sec)
MariaDB [book]> DROP TABLE users;
Query OK, 0 rows affected (0.00 sec)
MariaDB [book]> show tables;
Empty set (0.00 sec)
MariaDB [book]> drop database book;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]>
标签:big order 结构 delete img 5.5 常用函数 中文编码 一个
原文地址:https://www.cnblogs.com/hglibin/p/9557413.html