mysql 基本操做和問題

問題1:ERROR 1820 (HY000): You must SET PASSWORD before executing this statement數據庫

方法:SET PASSWORD = PASSWORD('123456');this




基本操做:spa

一、 顯示數據庫:show databases;
二、 建數據庫:create database  [if not exists] 數據庫名;
三、 建數據表: create table [if not exists] 表名 (字段名1   類型。。。。。。。。)
create table student (編號 int auto_increment primary key, 姓名 varchar(10));
注意:設置了自動增加,就要定爲主鍵,若是選擇了BIT 類型,0不顯示,非0顯示爲一個特殊符號!
四、 顯示數據表:show tables;
五、 刪除庫: drop database [if exists] 庫名; 
六、 刪除表: drop table   [if exists] 表名;
七、 顯示錶結構: desc 表名
八、 如何修改表結構:增加一個字段; alter table 表名 add 字段名  類型
九、         刪除一個字段: alter table  表名 drop 字段名
十、          修改一個字段的屬性:  alter table 表名modify 字段 新屬性
十一、 修改主鍵: 增長一個主鍵  alter table 表名 add primary key(字段名)
十二、          刪除一個主鍵  alter table 表名  drop primary key(字段名)rem

相關文章
相關標籤/搜索