Wednesday, April 13, 2016

CST 363 Week 7

Week 7

The material this week was pretty easy, at least easy to follow. The string manipulation we did was very similar to string manipulation in other regular programming languages. Most of the links were to regular Oracle database documentation and it's all pretty straight forward there. Overall, it's pretty difficult to read documentation when you aren't looking to do something specific so I had a difficult time staying focused there.

This week we covered the following ideas:
  • Creating a sequence table to be used for automatically incrementing values in a table we're already using. The most basic command to get up and running is CREATE TABLE sequenceName. The user utilizes this by calling for the next value, like INSERT INTO tableName VALUES (sequenceName.NextVal, …); (professor's example).
  • Creating aliases for columns. The user has the power to change column names, but they can also temporarily display alternate names just for the temporary use of a particular display. This can be done by adding the alias directly after the column name in a select statement or by specifying "as", like SELECT EName as "Student's Name" FROM STUDENT or SELECT ENAME Stu_Name FROM STUDENT. This can also be done for tables, like SELECT * FROM STUDENT s, CLASS c WHERE s.CLASS_ID = c.ID;
  • Adding padding to the left or the right of a particular string with "lpad" and "rpad".
  • Removing extra whitespace characters to the left and right hand side of a string with "ltrim" and "rtrim".
  • Using "substr" to get a subsection of a string.
  • Utilizing "sysdate" to show the current date. The sysdate variable can be incremented up and down by the day by just adding/removing an integer, like "sysdate+1" to get tomorrow's date. The date can also be formatted for the column to provide more details as well as compared to other existing dates in the database.


No comments:

Post a Comment