當前位置:首頁 > 數碼科技

命令行mysql建立數據庫和表

Q1:MYSQL數據庫中怎麼建立一個表呢?

進入mysql的命令窗口,敲命令:
create database 數據庫名;
use 數據庫名;
create table 表名(id int(4) not null primary key auot_increment; 字段名 數據類型;)

Q2:mysql數據庫怎麼創建數據表並添加數據

1、創建一個數據庫test2

代碼:mysql>createdatabasetest2;

截圖:

2、創建一個mytable表

代碼: mysql> create table mytable (name varchar(20), sex char(1),

-> birth date, birthaddr varchar(20));

截圖:

3、顯示錶結構

代碼:mysql> describe mytable;

截圖:

4、向表中插入一條記錄

代碼:mysql>insertintomytable

->values(

->abc,f,1988-07-07,chian);

截圖:

Q3:在dos命令下建立mysql數據庫的表

這樣就行了,
create table maxs(
friend_max int not null auto_increment,
diary_max int not null,
album_max int not null,
photo_max int not null,
comment_max int not null,
visit_max int not null,
user_max int not null,
head_max int not null,
p_comment_max int not null,
primary key(friend_max)
);
還有,別忘了選擇數據庫,就是在開頭兒的地方加上 “use 數據庫名”。

Q4:在MySQL中怎樣創建一個數據庫和數據表啊!!

在cmd命令提示符下輸入
mysql -u root -p回車,然後輸入密碼回車
進入mysql命令行模式
create database databasename;//創建數據庫
use databasename;//使用數據庫
create table tablename(
id int not null primary key
);
這樣就創建了一個只有id字段的tablename表

猜你喜歡

更多
此页面为HK繁体版,其他版本: 中文简体 | TW 繁体