Karellism

Basic SQL

Feb 11th, 2020
893
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.01 KB | None | 0 0
  1.     -- Create a new database with name DemoDB and with the character set
  2.     -- utf8 which stands for unicode text format 8 which is widely used for
  3.     -- supporting international character set.
  4.      
  5.     CREATE DATABASE `DemoDB` DEFAULT CHARACTER SET `utf8` ;
  6.      
  7.     -- USE command will select the Database.
  8.      
  9.     USE `DemoDB`;
  10.      
  11.     -- Create table to create the table in the database.
  12.              
  13.     CREATE TABLE `Employee`(
  14.         `EmpID`         INT,
  15.         `FirstName`     VARCHAR(50),
  16.         `LastName`      VARCHAR(50),
  17.         `Salary`        NUMERIC(20,2)
  18.     );
  19.      
  20.      
  21.     -- Insert command to inserting data into the table.
  22.      
  23.     INSERT INTO `Employee`
  24.     VALUES (1, 'A', 'A', 1000);
  25.      
  26.     INSERT INTO `Employee`
  27.     VALUES (2, 'B', 'B', 2000);
  28.        
  29.     -- Select Command or Query
  30.     -- used to retrieve the information from the table or relation.
  31.      
  32.     SELECT * FROM `Employee`;
  33.      
  34.     -- Drop command to drop the table.
  35.      
  36.     DROP TABLE `Employee`;
Advertisement