MySQL如何建立查詢資料

2021-08-19 18:08:29 字數 736 閱讀 1089

1. 建

資料庫create database 1name;      建成後use 1name;

2. 建資料表

create table `2name`( `name1`     資料型別(字元長度)  not null ,`name2`     資料型別(字元長度)  nut null ,  .........);

注:not null 可不輸入。

3. 插入資料

insert into  2name  (name1,name2,.....)  values  ('內容1','內容2',........);

或  insert into  2name  values  ('內容1','內容2',........);  --> 必須將定義的資料全打一遍。

注:輸入內容也可用「 」,但最好用  ' '   ;一次只能輸入一條資料。

4. 查資料

show databases;-->use 所查資料庫名;-->show tables;-->select * from 所查資料表名;

select 表1 . *,表2 . x from 表1,表2 where 表1.did=表2.id; --> 顯示表1中的did = 表2中的id時的全部表1資訊及表2的x資訊。

注:*表示全部,x,id表示 表2中的乙個資料,did表示 表1中的乙個資料。

注:alter table 資料表名 convert to character set utf8;    識別漢語。

mysql如何建立外檢 mysql如何建立外來鍵

乙個主表blog部落格表,drop table if exists blog create table blog id int 11 not null auto increment,title varchar 11 default null,content varchar 11 default nu...

mysql表如何建立 如何建立mysql表?

mysql中建立資料表的語法為 create table table name column name column type 在mysql 提示符下,建立乙個mysql表這是很容易的。使用 sql 命令 create table 來建立表。在建立表前需要使用use databasename命令選擇...

mysql 新建查詢 mysql 查詢建立儲存過程

mysql儲存過程基本函式 一.字串類 charset str 返回字串字符集 concat string2 連線字串 instr string substring 返回substring首次在string 現的位置,不存在返回0 lcase string2 轉換成小寫 left string2 l...