Learn how you can use triggers to create timestamps in the table you are inserting or updating, and in other tables too.
- [Narrator] Triggers may be used to create timestamps.…In this example I will show you how to use a trigger…to create timestamps and to update a transaction log.…We'll be using the test date base,…and copying and pasting from the chapter ten exercise files.…I'm just gonna grab a bunch of stuff here.…All the way down to that select from,…and drop that into the SQL.…Here we're gonna drop our existing tables,…and create new ones that include these timestamp columns.…And also a whole new table for a log.…
And I'll populate our customer table,…and we'll go ahead and execute this.…We see both last order ID and stamp are null here.…So let's go out and grab our trigger,…copy all the way down to here,…and paste that in here.…Now this trigger is a little bit more complex…than some of the others we've seen.…This is after insert, which we've seen before.…
And now we have several lines of SQL inside of our trigger.…The first one will set the timestamp on…the widget sale table.…And it'll also set the last order ID like we've seen before,…
- Understanding SQL terminology and syntax
- Creating new tables
- Inserting and updating data
- Writing basic SQL queries
- Sorting and filtering
- Accessing related tables with JOIN
- Working with strings
- Understanding numeric types
- Using aggregate functions and transactions
- Automating data with triggers
- Creating views
- Defining functions in PHP
Skill Level Beginner
2. SQL Overview
3. Fundamental Concepts
7. Dates and Times
Dates and times1m 52s
11. Views and Subselects
12. Defined Functions
13. A Simple CRUD Application
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.