2019 10 9 資料庫的命令

2022-08-22 00:24:15 字數 1149 閱讀 8436

資料庫的命令:

檢視所有資料庫:show databases;

檢視當前使用的資料庫:select databases();

切換資料庫:use 資料庫名;

建立資料庫:create database 資料庫名 charser=utf8;

刪除資料庫:drop databases 資料庫名;

資料庫表的命令:

檢視所有表:show tables;

建立表:create table 表名(id int auto_increment primary key not null,...);

刪除表:drop table 表名;

修改表:alter table 表名 add|change|drop 列;

資料庫的命令crud:

查詢:select * from 表名;

增加:insert into 表名 values(...);

修改:update 表名 set 字段=值...

刪除:delete from 表名

邏輯刪除:本質就是修改

邏輯運算子:

andor

not查詢編號大於3的女生

select * from students where id>3 and gender=0;

查詢編號小於4或沒被刪除的學生

select * from students where id<4 or isdelete=0;

模糊查詢:like

查詢姓黃或叫靖的學生

select * from students where name like '黃%' or name like 『%靖』;

範圍查詢:

查詢編號是1或3或8的學生

select * from students where id in(1,3,8);

查詢學生是3至8的男生

select * from students where id between 3 and 8 and gender=1;

空判斷、

查詢生日為空的學生

select * from students where birthday is null;

查詢生日不為空的學生:select * from students where birthday is not null;

啟動資料庫的命令

root localhost root su oracle oracle localhost oracle sqlplus as sysdba sql plus release 9.2.0.4.0 production on 星期一 4月 10 10 41 53 2006 connected to ...

PostgreSQL 資料庫的命令

系統命令行視窗 查詢退出 q 備註root izuf624rjpfgj95cg9aw9fz su postgres postgres izuf624rjpfgj95cg9aw9fz postgres izuf624rjpfgj95cg9aw9fz psql postgres postgres l p...

資料庫的操作命令

資料庫操作 增刪改查 增加資料庫 create database 資料庫名 刪除資料庫 drop database 資料庫名 檢視所有資料庫 show databases 檢視當前的資料庫 select database 切換資料庫 use 資料庫名 表操作 增加乙個表 create table 表...