Sql命令行
查看命令
1. 查看数据库: `show databases;` 2. 使用数据库: `use test` 3. 查看表: `show tables;` 4. 查看表内的列: `show columns from su;` or `describe su;` 5. 查看字段 `select *from su;` 6. 重命名: `alter table 表名 rename to 新表名;`创建命令
1. 创建数据库: `create database test` 2. 创建表: create table su
(
id int(10) not null,
content char(60) null,
primary key(id)
);
插入命令
1. 将行插入表: insert into su
(id,content)
values
(0,'haha'),
(1,"haha2"),
(2,'haha3');
- 将列插入表:
alter table 表名 add column 列名 varchar(30);
删除命令
1. 删除行: delete * from 表名 where id = '';
-
删除列:
alter table 表名 drop column 列名;
-
删除表:
drop table 表名;
-
删除数据库:
drop database 数据库名;
更改命令
1. 更改字段:update table_name set column_name="" where column_name=""