Preview

Writing Sql Statement

Good Essays
Open Document
Open Document
478 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Writing Sql Statement
MySQL – Creating Databases and Tables
1. 2. Select Start -> MySQL -> MySQL Server 5.1 -> MySQL Command Line Client. Enter password to access the MySQL server. The password is specified when MySQL is installed. 3. Type CREATE DATABASE mydatabase to create the database.

4.

Type USE mydatabase; to inform the system that all SQL commands that follow is using mydatabase. If database is found, the system will respond with: Database changed

5. 6. 7.

Copy the create_table.sql script file to c:\script. Open the file in text editor to view the sql statement. Type source c:\script\create_table.sql to create the friends table. If you type the wrong pathname, an error will be displayed. Otherwise, the system responds with: Query ok, 0 rows affected (0.08sec)

8.

Type the following command to display the column details of the table: DESCRIBE friends;

MySQL – Inserting Data into Tables
1. The INSERT SQL statement populate table with data. The general form of INSERT: INSERT INTO table_name(column1, column2, column3, ...) values (value1, value2, value3, ...); 2. Type the following statement to insert the first record in friends table: INSERT INTO friends(ID, Fname, Phone) values (1, “Tan Mei Mei”, “91234123”);

3.

To insert more records, we need to type separate INSERT statements. In order to make life easy, we create a script file insert_friends.sql with as many INSERT statements as we like. Do you remember how to run the script file?

4.

Run the script file and type the following statements to check the INSERT operation: SELECT * from friends;

MySQL – Querying and Updating Tables
1. The SELECT SQL statement queries table to get data. The general form of SELECT: SELECT column1, column2, ... from table_name [WHERE conditions];

2.

Type the following statement to get all fields and all records in friends table: SELECT * from friends; This SELECT statement has no [where] condition. As such, all records are retrieved from the table.

3.

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Pt1420 Unit 4

    • 380 Words
    • 2 Pages

    To insert a new column, place the insertion point in an _____adjacent______ column before choosing Insert Right or Insert Left.…

    • 380 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Nt1330 Unit 9 Final Paper

    • 491 Words
    • 2 Pages

    You can also see the generated script if in case you needed it, for this you have to select the table then select generate change script from context menu. Bellow I have given a screen show which shows the table “user”’s generated script in a dialog window.…

    • 491 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    If you do not allow nulls, you must enter a value into the column to continue.…

    • 327 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    a guide to mysql ch 7

    • 1287 Words
    • 9 Pages

    Except where indicated, use MySQL Query Browser to perform each operation and print the results.…

    • 1287 Words
    • 9 Pages
    Powerful Essays
  • Satisfactory Essays

    drawing511

    • 329 Words
    • 10 Pages

    User 0.. * Friend 1 UserID (key) 0 ..* FriendID(key) 1 UserID1 UserID2 Date 1 Password…

    • 329 Words
    • 10 Pages
    Satisfactory Essays
  • Powerful Essays

    Unit 18 - Database P1, M1

    • 995 Words
    • 4 Pages

    A Table is where you are organised and store data so you have to create the table before store any data. By creating table, you need to define few things, Fields name, Data type, and the Description.…

    • 995 Words
    • 4 Pages
    Powerful Essays
  • Powerful Essays

    b) You are to clearly mark Primary and Foreign Keys as shown in the sample below:…

    • 1494 Words
    • 19 Pages
    Powerful Essays
  • Better Essays

    With quickly accessing people’s information being very important as you don’t want to keep the customer working, being able to perform a complex query is critical. This can be done thanks to a language called TSL, which was developed to allow people to ‘Insert’, ’Update’, ‘Delete’, ‘Create’ and ‘Drop’ table records. You can narrow down these records even more if you use the ‘Where’ clause.…

    • 3057 Words
    • 9 Pages
    Better Essays
  • Good Essays

    07

    • 4772 Words
    • 25 Pages

    12) Data values to be added to a table are specified by using the SQL VALUES clause.…

    • 4772 Words
    • 25 Pages
    Good Essays
  • Satisfactory Essays

    SQL Queries

    • 423 Words
    • 2 Pages

    These tables would be linked together by foreign keys; Enroll Table would be linked to Student table by FKStuID; Class would be linked to Enroll Table by FK ClassID…

    • 423 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    • Develop at least two tables, using the same step of the accounting cycle selected for your previous Learning Team assignments, that could be used in a database for your selected accounting cycle.…

    • 103 Words
    • 1 Page
    Satisfactory Essays
  • Good Essays

    Week 1 Submission

    • 1120 Words
    • 5 Pages

    Copy the demo.sql file from the Doc Share to the C:\temp directory. At the sql prompt enter the command @V:\temp\demo.sql. This will create some tables and insert data into them. View the script in notepad to determine the table names that were created. Use the describe command to view the structure of the tables. Please use the template below to provide your solutions.…

    • 1120 Words
    • 5 Pages
    Good Essays
  • Good Essays

    Juliet uses many metaphors and allusions to demonstrate or describe her thoughts and lust for Romeo. She begins her riddle of allusions by asking phaeton’ s carriage to bring in the dark of night for Romeo to arrive in this quote(3.2.2) “ Toward Phoebus lodging such a wagoner driver.” . She then thinks of how fast the night will come and how much she wants the night to come in this following saying of Juliet (3.2.4)“ bring in the cloudy night immediately.” . Romeo is supposed to come to Juliet at night, by climbing up the ladder. She hopes when he climbs up the ladder he will do what Juliet says in this following line (3.2.7) “ Leap to these arms untalked of and unseen.” She is anxiously dreaming and thinking of her husband arrival.…

    • 299 Words
    • 2 Pages
    Good Essays
  • Good Essays

    "SQL History and Revisions." 30 Tutorial Books by Herong Yang on Software Programming Technologies. N.p., n.d. Web. 26 Sept. 2012. <http://www.herongyang.com/MySQL/SQL-History-and-Revisions.html>.…

    • 701 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Complete Exercise 5 on page 284 Write SQL commands for the following: a. Create two different forms of the INSERT command to add a student with a student ID of 65798 and last name Lopez to the Student table. b. Now write a command that will remove Lopez from the Student table. c. Create an SQL command that will modify the name of course ISM 4212 from Database to Introduction to Relational Databases…

    • 368 Words
    • 1 Page
    Satisfactory Essays

Related Topics