標籤:sel inno 刪除表 儲存 dex values book 練習 select
三十四 資料庫
1、 查看資料庫命令
2、 使用某個資料庫
3、 查看當前在哪個庫
4、 查看當前資料庫中有哪些表
5、 查詢表中資料
6、 建庫:create database testbase;
7、 建表:create table user(id int not null);
建立表,名字為user_wangjing,欄位為 id,date1,date2等
建立表名,括弧裡意思是int 11位,不可為空
8、 插入資料:insert into user values(1);
9、 查看錶的資訊:
10、 刪除表
11、 刪除庫:drop database testbase;
12、 建立使用者:
create user ‘student11‘@‘%‘ identified by "gloryroad";
FLUSH PRIVILEGES;
%表示所有IP都可登入,‘student11‘@‘10.60.89.%‘表示只有這個欄位的IP可以登入
13、 修改密碼:
UPDATE USER SET PASSWORD=PASSWORD(‘12345622xw1‘) WHERE USER=‘gg1‘;
FLUSH PRIVILEGES;
14、 建立使用者和修改使用者的許可權
grant all privileges on test.user to [email protected]"%" identified by "gloryroad" ; #讓使用者擁有操作任意資料庫的許可權
flush privileges;
15、 建表,插入值
ENGINE=InnoDB儲存資料庫採用innoDB引擎,如果你想使用外鍵,事務等功能,就需要innodb引擎
16、 查看錶的欄位和屬性: show columns from book_wangjing;
17、 查看索引:SHOW INDEX FROM book_wangjing;
18、 查看2條資料,從頭開始前兩條不看,列印接著後面的
19、 查看2條之後的3條
20、 查詢表資料 and or:
21、 給表中的欄位起一個別名
22、 表中欄位的排序
select * from book where book_author like ‘%老師‘;
計算表中資料條數:
計算平均值:
【Python】資料庫練習-1