StayWell manages the owner information about every property under their management. Since the owners are essential to the operations, their addresses (with city, state, and zip code) are collected. Create the OWNER table, it should have the following data? OWNER_NUM as fixed-length 5 characters LAST_NAME as maximum 20 characters FIRST_NAME as maximum 20 characters ADDRESS as maximum 100 characters CITY as maximum 20 characters STATE as fixed-length 2 characters ZIP_CODE as fixed-length 5 characters All fields are mandatory and cannot be empty
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
StayWell manages the owner information about every property under their management. Since the owners are essential to the operations, their addresses (with city, state, and zip code) are collected. Create the OWNER table, it should have the following data?
- OWNER_NUM as fixed-length 5 characters
- LAST_NAME as maximum 20 characters
- FIRST_NAME as maximum 20 characters
- ADDRESS as maximum 100 characters
- CITY as maximum 20 characters
- STATE as fixed-length 2 characters
- ZIP_CODE as fixed-length 5 characters
All fields are mandatory and cannot be empty
CREATE TABLE OWNER (
OWNER_NUM CHAR(5) NOT NULL,
LAST_NAME VARCHAR(20) NOT NULL,
FIRST_NAME VARCHAR(20) NOT NULL,
ADDRESS VARCHAR(100) NOT NULL,
CITY VARCHAR(20) NOT NULL,
STATE CHAR(2) NOT NULL,
ZIP_CODE CHAR(5) NOT NULL,
PRIMARY KEY (OWNER_NUM)
);
You can then insert data into the table using an INSERT INTO
statement:
INSERT INTO OWNER (OWNER_NUM, LAST_NAME, FIRST_NAME, ADDRESS, CITY, STATE, ZIP_CODE)
VALUES ('00001', 'Smith', 'John', '123 Main St', 'Anytown', 'NY', '11111'),
('00002', 'Johnson', 'Jane', '456 Elm St', 'Anytown', 'NY', '11112'),
('00003', 'Williams', 'Jim', '789 Oak St', 'Anytown', 'NY', '11113');
Finally, you can retrieve the data from the table using a SELECT
statement:
SELECT * FROM OWNER;
This will return the following data:
OWNER_NUM | LAST_NAME | FIRST_NAME | ADDRESS | CITY | STATE | ZIP_CODE
----------|-----------|----------- |----------------------|-----------|-------|---------
00001 | Smith | John | 123 Main St | Anytown | NY | 11111
00002 | Johnson | Jane | 456 Elm St | Anytown | NY | 11112
00003 | Williams | Jim | 789 Oak St | Anytown | NY | 11113
Trending now
This is a popular solution!
Step by step
Solved in 2 steps