MySQL基礎-建立資料庫和表,mysql資料庫

來源:互聯網
上載者:User

MySQL基礎-建立資料庫和表,mysql資料庫

MySQL基礎-建立資料庫和表

顯示資料庫一覽show databases; (SQL命令本身不區分大小寫)

mysql> show databases;

Database

information_schema

mysql

test

小結:information_schema資料庫又稱資訊架構,管理從表開始的資料庫組成資訊,以及使用者管理資訊的檢索專用的資料庫。確認這些資料庫內容就可以掌握現在資料庫的狀態。不可在mysql和information_shema資料庫中儲存使用者經常使用的資料。最後的test資料庫是測試用的資料庫,安裝mysql會自動建立test資料庫,資料庫本身是空的。



mysql 在B資料庫下 建立一個與A資料庫中一樣的表

create table B.test as select * from A.test;--------------結構,資料內容一致,但是不會複製索引以及外鍵
所以分兩步:
1:create table B.test like A.test;-------複製表結構
2:insert into B.test select * from A.test;----------複製資料
 
MYsql資料庫怎建立表?

CREATE DATABASE cookbook; 建立一個叫“cookbook”的資料庫

USE cookbook; 使用cookbook這個資料庫
CREATE TABLE limbs (thing VARCHAR(20),legs INT,arms INT); 建立表“limbs”其中包括thing,legs,aems 欄位
建立表的命令是 CREATE TABLE 表名稱
後面括弧裡的內容是表中欄位的屬性
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.