mysql基本语法DLL语句;
1,进入mysql的方法.
1.1 dos命令 mysql -uroot -p 1.2控制面板进入
2.1查询库,show databases; 创建库;create database 库名; 删除库;drop database 库名;
2.2创建表,use 库(如果不自己创建的库,都将存入mysql库中) 创建表;create table 表名( name(字段) varchar(字段类型), id(字段) int(字段类型)); 查询库中的表 show tables; 查询表的结构 desc 表名; 修改字段 change 语法; alter table 表名 change 旧字符段 新字符段 旧字符类型. 修改字符段类型alter table 表名 modify 字符段 新字符按段类型; 添加列;alter table 表名 add 字符段名 字符段类型;删除列;alter table 表名 drop 新的字符但类型;
mysqcl的数据类型;int 整形; varchar字符串; double小数 date日期格式
mysql> use my_2203;
Database changed
mysql> show tables;
+-------------------+
| Tables_in_my_2203 |
+-------------------+
| person |
+-------------------+
1 row in set (0.00 sec)
mysql> decs person;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'decs person' at line 1
mysql> desc person;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| username | varchar(20) | YES | | NULL | |
| brithday | date | YES | | NULL | |
| gender | varchar(50) | YES | | NULL | |
| email | varchar(40) | YES | | NULL | |
| age | int(11) | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
6 rows in set (0.01 sec)
mysql> select *from person;
+------+----------+------------+--------+----------+------+
| id | username | brithday | gender | email | age |
+------+----------+------------+--------+----------+------+
| 1 | zhaosi | 2000-02-05 | nan | 1212.con | 15 |
| 1 | zhaosi | 2000-02-05 | nan | 1212.con | 15 |
| 1 | zhaosi | 2000-02-05 | nan | 4848.con | 28 |
+------+----------+------------+--------+----------+------+
3 rows in set (0.00 sec)
mysql>