MYSQL 操作

看一下mysql的版本信息:
? ~ brew info mysql
mysql: stable 5.7.16 (bottled)

打開mysql服務:

mysql.server start

好了,進入mysql看下:

? ~ mysql -u root -p

mysql查看表結構命令,如下:

desc 表名;
show columns from 表名;
describe 表名;
show create table 表名;

use information_schema
select * from columns where table_name='表名';

查看數(shù)據(jù)庫:

show databases;
// 使用數(shù)據(jù)庫
use 數(shù)據(jù)庫名;
show tables;

創(chuàng)建數(shù)據(jù)庫,創(chuàng)建表。

mysql> create database ssh2;  

mysql> use ssh2;  

mysql> create table user(  
    -> id integer primary key,  
    -> firstname varchar(200) not null,  
    -> lastname varchar(200) not null,  
    -> age integer  
    -> );  

給主鍵增加一個自增的功能:
mysql> alter table user modify id integer auto_increment;

這樣,上面的user表里面的主鍵,id可以自增了。

鏈接:
http://stevenjohn.iteye.com/blog/976397

增刪改查:http://blog.chinaunix.net/uid-20672803-id-3049747.html

php操縱數(shù)據(jù)庫:http://www.runoob.com/php/php-mysql-select.html

最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容