MySQL storage engine with table creation, key definition, etc.

Source: Internet
Author: User

--select * from Products--select prod_name from Products/*limit 7 offset 2 */--take 7 rows of data from the second row, if less than 7 rows, then take the actual number of rows--limit 2,7--equivalent

Hand shake to turn over the village board, scared the notebook hard drive offline, after restarting only the above this exercise, the following is today to practice MySQL on the table

select * from ordersorder by 2,3show enginesshow variables like  ' %innodb% ' show variables like  '%storage_engine% '  --view MySQL's current default storage engine:show table  status from test where name = ' Test '--View the storage engine information of the test library's test table----Create a table and specify its storage engine as Innodbuse  TESTcreate table test_engine  (id int not null auto_increment,  Temp varchar (),--varchar type requires a specified length, otherwise an error cannot be created table  primary key  (ID)  )  engine =  innodb--Change the table's storage engine alter table engine= myisam--error, don't know why--Little practice 1CREATE TABLE EXAMPLE0 (Id int not null auto_increment primary key,  name varchar (20),   sex  boolean           -- Equivalent to tinyint (1)   )--small exercise 2--combined primary key USE TESTCREATE TABLE SC (Sno int not null, Cno int not nuLl,/* suddenly remembered the problem of select 2 from table, test it use world;select 2 from world.city  --results for a column n rows of 2,n for the city table row number */grade int default  ' 0 ',--can not be less comma, even if there is no attribute declaration only the primary key definition ... primary key  (SNO,CNO)) USE TEST;CREATE TABLE SC (sno int ,--there were not  before null  and then create it all the time. cno int ,--Ibid. Is this the reason for the above example? Do not understand why, experiment a bit) grade int default  ' 0 ',primary key  (sno,cno)) create table  Example1 (id int not null auto_increment primary key,  name  varchar (20),--did not add the error, why?   sex  boolean  )/* The foreign key of the child table must be the primary key of the parent table, and the data type should be consistent */create table example3 (ID  int primary key, stu_id int, course_id int, constraint c_fk  foreign key (stu_id,course_id)  references example2 (stu_id,course_id)  --error, The Example3 table could not be created. Querying a book, may be dependent on the Example2 table and its attributes do not exist  --first come back to create the table example2 ) CREATE&NBsp;table example2 (stu_id int,  course_id int,  grade float,   primary key (stu_id,course_id)  ) Create table example3 (id int primary  Key, stu_id int, course_id int, constraint c_fk foreign key (stu_id, course_id)  references example2 (stu_id,course_id)   )  --command (s)  completed  successfully./* field uniqueness constraint, field self-increment property, field default value (in the previous example, the int default value of 0 does not add ' "error, and then pre-experiment) */ --The small Exercise 2 copied over, the following examples are numbered, convenient to call ...   CREATE TABLE SC1 (Sno int not null,cno int not null,grade  int default 0,primary key  (SNO,CNO))--command (s)  completed  Successfully. I guess I made a mistake.   --Little Practice 3 create table example7 (id int primary  Key auto_increment,   stu_id int unique,   name varchar (20)  not null,   english&Nbsp;varchar  default  ' zero ',   math float default 0,    Computer Float default 0   )  --command (s)  completed  Successfully. End of practice on tables


MySQL storage engine with table creation, key definition, etc.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.