資料庫基本操作

2021-08-17 05:00:12 字數 683 閱讀 4726

mysql常用的操作命令:

mysql -h ip -u root (data_base)

show databases;  檢視資料庫中的所有庫

use data_base; 選擇data_base這個資料庫

show tables;檢視data_base這個庫中的表

desc data_table;開啟表中的data_table這張表

建立create database 資料庫名;//建立資料庫

刪drop database 《資料庫名》;  //刪除資料庫

show global variables like 'port';  //檢視mysql埠號

select table_schema,table_name,create_time from information_schema.tables where table_name='表名';

查select * from mytable;

檢視表mytable全部資料

select user, password, host from user;  檢視表user中的

現有使用者,密碼及允許連線的主機

改修改資料庫表的某欄位:

update mytable set aaa = 3 where id = 6;  //修改表mytable中id為6的資料中欄位aaa的值為3

資料庫 資料庫基本操作

操作練習 修改表結構 表資料的操作 實現 1 建立表 create table student stu no char 12 not null primary key,stu name varchar 20 not null gender tinyint 1 default1,age tinyint...

資料庫基本操作

1.查詢一周之內的資料 select from 表名 where date sub curdate interval 7 day date 欄位名 2.插入 年 月 日 時 分 秒的時間 pstmt.settimestamp 7,new timestamp system.currenttimemil...

資料庫基本操作

登入資料庫系統 mysql h localhost u root p 檢視已存在的資料庫 show databases 檢視預設儲存引擎 show variables like storage engine 建立資料庫 create database 想建立的資料庫名字 刪除資料庫 drop dat...