Get start with TiDB - Explore SQL with TiDB

25 Jun, 2021
play with TiDB SQL

Previously on Phoebe’s get started with TIDB trilogy: we used TiUP and deployed our sandbox environment - playground. We have also successfully connected to mysql client. Now we are ready for the SQL fun.

Pre-requisite for this tutorial: Get start with TiDB - Setup a sandbox in 5 minutes

You will run all the following commands in the mysql client.

  1. Create a database for customer data:

    Create database customerDB;

  2. Switch to the new customer database:

    Use customerDB;

  3. Create a customer table that contains basic customer information:

    Create table customer( id integer NOT NULL PRIMARY KEY, firstname varchar (255), lastname varchar (255), username varchar (255), membership varchar (255) );

  4. Insert some data into the new table:

    Insert into customer (id,firstname, lastname, username, membership) values (1,'Maria', 'Clarke', 'mclark','RPEMIUM'), (2,'Terrence', 'Walker', 'twalker', 'STANDARD'), (3,'Charles', 'Bing','cbing','FREE'), (4,'Ray', 'Smiths', 'rsmiths', 'FREE'), (5,'Rhonda', 'Clarke', 'rclarke', 'PREMIUM');

  5. Run some very very very basic queries

    Select count(*) from customer; Select username from customer where membership = 'FREE';

That’s it! Worked as any SQL database. In the next tutorial, we will run an application use TiDB as the database engine.

© 2021 GEEK SG. All rights reserved.