create table test
(
code varchar(20) primary key,
name varchar(20)
);

keyword
primary key Primary key
Non empty not null
foreign key( Name )references Main table name ( Name ) Foreign keys
Combined the primary key ( Table cannot find primary key )
Self growth column auto_increment( Table cannot find primary key )
Be careful :1. Each statement is followed by a semicolon ,2. There is no comma in the last column 3. If the symbol is in Chinese

create table test
(
code varchar(20) primary key,
name varchar(20) not null
);

create table zhu
(
code int(20) primary key,
name varchar(20)
);

create table cong
(
code int(20) primary key,
name varchar(20),
zhu int,
foreign key (zhu) references zhu(code)
);

create table haoyou
(
ids int auto_increment primary key,
me varchar(20),
friends varchar(20)

)

Homework
1. Modify the table statement
Two We have to add, delete, modify and check the data CRUD
Add data :
insert into Table name values('','');
insert into Table name ( Name ) values('');
Be careful :1. If you add The data is a string , Need to add '', Don't add other types .
2. When adding data, the number of values should match the number of columns
3. Add a separate piece of data insert into Table name ( Name ) values('');
4. If the column you want to add is self growing, you can give it a null value

12-1 In the morning mysql More articles on basic sentences

  1. mysql sql Corpus of sentences ( Reprint )

      1. explain : Create database CREATE DATABASE database-name 2. explain : Delete database drop database dbname 3. explain : Backup sql server --- establish ...

  2. MySql Application statement

    [1]MySQL Basic statement -- Inquire about mysql Version number SELECT VERSION(); -- Create database DROP DATABASE IF EXISTS study; -- If it exists, delete it first CREA ...

  3. MYSQL A collection of query statements

    MYSQL A collection of query statements 1: Use SHOW Statement to find out what database currently exists on the server : mysql> SHOW DATABASES; 2:2. Create a database MYSQLDATA mysql> C ...

  4. linux strace track mysql Execute statement (mysqld --debug)

    Reprint please indicate the source : Use strace Tracking multiple processes  http://www.ttlsa.com/html/1841.html http://blog.itpub.net/26250550/viewspace- ...

  5. Springboot The interface is simple to realize generation MySQL Insert statement

    Springboot Interface simple implementation calls interface generation MySQL Insert statement In the actual test , There is a demand scenario , such as : In performance stress testing , Maybe we need to insert some related data in the database in advance . We're actually testing , Have a problem , Need to be ...

  6. MySQL A complete collection of commonly used sentences

    MySQL A complete collection of commonly used sentences One . Connect MySQL Format : mysql -h The host address -u user name -p User password 1. example 1: Connected to the MYSQL. First on DOS window , Then go to the directory my ...

  7. php Interview topics ---MYSQL Query statement optimization

    php Interview topics ---MYSQL Query statement optimization One . summary One sentence summary : mysql The performance optimization of is very extensive : Index optimization , Query optimization , The query cache , Server setup optimization , Operating system and hardware optimization , Application level optimization (web The server , cache ) ...

  8. MySQL The order in which the statements are executed

    MySQL The order in which the statements are executed MySQL The statements are divided into 11 Step , As shown in the figure below , The first thing to do is always FROM operation , The last thing to do is LIMIT operation . Each of these operations produces a virtual table , This virtual table serves as a processing input ...

  9. strace track mysql Execute statement

    One .strace Parameters strace yes Linux Under the environment of a program debugging tool , Used to monitor the system calls used by an application and the system information it receives . Tracking the entire life cycle of a program at run time , Output the name of each system call , Parameters , Return values and ...

Random recommendation

  1. [SHOI2008] Traffic jams traffic

    I'm Mengmeng's portal To put it bluntly, this is a graph connectivity maintenance that supports adding and deleting edges , But in view of the particularity of graphs , You can directly segment the tree ( It's said that this is the standard calculation --). But I'm lazy , I don't want to think about how to segment trees , So I wrote a division and collection ,1A I am ...

  2. Eclipse Open the folder where the current file is located

    The two methods : 1. install EasyExplorer plug-in unit , With this plug-in, you can easily open the folder where the resource file is located . EasyExplorer from  http://sourceforge.net/projects/ ...

  3. install and configure Symfony

    To simplify the process of creating new projects ,Symfony Provide an installation program . install Symfony Installer Use Symfony Installer Is to create a new one Symfony The only way to recommend a project , This install ...

  4. redis Linked list

    redis Linked list Preface Learn from it Huang Jianhong Of <<Redis Design and implementation >> A Book , Yes redis Learning from source code We welcome your comments , Communicate and learn from each other summary redis Link list structure of ...

  5. [android] android Next create a sqlite database

    Sqlite The database is open source c Database written in language ,android and iphone They all use this , First you need to create a database , Then create tables and fields ,android Provides a api It's called SQLiteOpenHelper Open the database ...

  6. sql in , How to get the number of months before two dates 、 Weeks 、 Days

    1. Gets the number of months between two dates . Weeks . Days grammar --1. Gets the number of months between two dates . Weeks . Days --1.1) Declare parameters ) ) --1.2) Get the number of months directly from two dates select DATEDIFF(MM,@sta ...

  7. JS Regular expressions go from the beginning to the end (1)—— REGEXP object

    REGEXP object JavaScript Through built-in objects RegExp regular expression , There are two ways to instantiate RegExp object . 1. Literal 2. Constructors Literal The literal quantity is directly through /.../ establish RegExp Object instances . ...

  8. The first 9 Chapter HBase operation

    Catalog 9.1 Cluster environment construction 1. Upload and unzip HBase Installation package 2.hbase-env.sh File configuration 3.hbase-site.xml File configuration 4.regionservers File configuration 5. Copy hbase To its ...

  9. GIT Learning notes (2): Time machine shuttle and remote warehouse

    GIT Learning notes (2): Time machine shuttle and remote warehouse Cancel the operation 1.GIT How to track changes After we changed the content of the code , Yes git add and git commit Command to hand it over Git Version control . The example we gave earlier is like this ...

  10. linux Learning notes 1

    1.IDE Hard disk        /dev/hd[a-d]                   IDE1   Lord  /dev/hda   from /dev/hdb          IDE2         Lord ...