-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMySQL note
More file actions
24 lines (24 loc) · 1.29 KB
/
Copy pathMySQL note
File metadata and controls
24 lines (24 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
展示所有的数据库
show databases;
进入某一个数据库
use dbname;
展示当前数据库中所有的表
show tables;
创建一个表
create table users(id int(2) not null primary key auto_increment,username varchar(40),password text,email text)default charset=utf8;
查询表的结构
desc table_name;
比如查询上面所建的表,就是desc users; 结果为:
+----------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+----------------+
| id | int(2) | NO | PRI | NULL | auto_increment |
| username | varchar(40) | YES | | NULL | |
| password | text | YES | | NULL | |
| email | text | YES | | NULL | |
+----------+-------------+------+-----+---------+----------------+
4 rows in set (0.12 sec)
查询指定数据库中的指定的表的字段以及注释
select column_name, column_comment from information_schema.columns where table_schema ='db' and table_name = 'tablename' ;
向表中插入一条记录,以上面那个表为例
insert into users(username,password,email) values("xiaoming","123123","xiaoming@gmail.com");