Her

Home Web Programming PHP Introduction to SQL

Introduction to SQL

Author: allsyntax.com Author's URL: www.allsyntax.com More by this author

Update

We can change the information in existing rows in the database using the UPDATE statement.

UPDATE people SET location = 'Ohio' WHERE name = 'Jill'

Update the table people and change the location to Ohio WHERE the name is Jill.We could update more than one column field if we wanted.

UPDATE people SET location = 'Ohio', age = '25' WHERE name = 'Jill'

Just separate them with commas.

Create

We can use the CREATE TABLE statement to make new tables.

CREATE TABLE other_people( id INTEGER (11), name VARCHAR (255), gender VARCHAR (6), location VARCHAR (255), age INTEGER (3) )

Create a table named other_people, now we have to define each column field and the type of data it will contain, here is a list of some of them:

  • INTEGER - A whole number.
  • VARCHAR (10) - Up to 10 characters.
  • CHAR (10) - Only 10 characters.
  • DATE - A date.
  • DATETIME - Date and time.
  • FLOAT - Floating point numbers.

Read the SQL statement, it speaks for itself.

Drop

We can delete tables from our database with the DROP TABLE statement.

DROP TABLE other_people

It's as simple as that.

Conclusion

That about wraps up this introduction to SQL. This is the extreme basics, but it's these foundations you need so you can build on them and advance your skills in SQL.